Creating your first clan
Ready to manage your fleet of machines?
We will create a declarative infrastructure using clan, git, and nix flakes.
You'll finish with a centrally managed fleet, ready to import your existing NixOS configuration.
Prerequisites
Make sure you have the following:
- 💻 Administration Machine: Run the setup commands from this machine.
-
🛠️ Nix: The Nix package manager, installed on your administration machine.
How to install Nix (Linux / MacOS / NixOS)
On Linux or macOS:
-
Run the recommended installer:
-
After installation, ensure flakes are enabled by adding this line to
~/.config/nix/nix.conf:
On NixOS:
Nix is already installed. You only need to enable flakes for your user in your
Then, runconfiguration.nix:nixos-rebuild switchto apply the changes. -
-
🎯 Target Machine(s): A remote machine with SSH, or your local machine (if NixOS).
Create a New Clan
-
Navigate to your desired directory:
-
Create a new clan flake:
Note: This creates a new directory in your current location
-
Enter a name in the prompt:
Project Structure
Your new directory, my-clan, should contain the following structure:
Templates
This is the structure for the default template.
Use clan templates list and clan templates --help for available templates & more. Keep in mind that the exact files may change as templates evolve.
Activate the Environment
To get started, cd into your new project directory.
Now, activate the environment using one of the following methods.
First you need to install direnv to allow auto-loading .envrc bash files on cd
Ontop of that you need the nix-direnv addon.
-
Direnv needs to hook into your shell to work. You can do this by executing following command. The example below will setup direnv for
zshandbashecho 'eval "$(direnv hook zsh)"' >> ~/.zshrc && echo 'eval "$(direnv hook bash)"' >> ~/.bashrc && eval "$SHELL"Run
direnv allowto automatically load the environment whenever you enter this directory.
Verify the Setup
Once your environment is active, verify that the clan command is available by running:
You should see the default metadata for your new clan:
This confirms your setup is working correctly.
You can now change the default name and tld by editing the meta.name and meta.tld fields in your clan.nix file.