2024-04-13 15:46:07 +00:00
# Configuration - How to configure clan with your own machines
## Global configuration
In the `flake.nix` file:
2024-06-25 11:58:38 +00:00
- [x] set a unique `name` .
2024-04-13 15:46:07 +00:00
2024-04-16 10:02:22 +00:00
=== "**buildClan**"
```nix title="clan-core.lib.buildClan"
buildClan {
2024-06-15 20:27:37 +00:00
# Set a unique name
2024-06-25 11:58:38 +00:00
meta.name = "Lobsters";
2024-04-16 10:02:22 +00:00
# Should usually point to the directory of flake.nix
directory = ./.;
machines = {
jon = {
# ...
};
2024-04-13 15:46:07 +00:00
# ...
2024-04-16 10:02:22 +00:00
}
2024-04-13 15:46:07 +00:00
}
2024-04-16 10:02:22 +00:00
```
=== "**flakeParts**"
!!! info "See [Clan with flake-parts ](./flake-parts.md ) for help migrating to flake-parts."
```nix title="clan-core.flakeModules.default"
clan = {
2024-06-15 20:27:37 +00:00
# Set a unique name
2024-06-25 11:58:38 +00:00
meta.name = "Lobsters";
2024-04-16 10:02:22 +00:00
machines = {
jon = {
# ...
};
# ...
}
};
```
2024-04-13 15:46:07 +00:00
2024-04-13 17:39:11 +00:00
## Machine configuration
2024-04-13 15:46:07 +00:00
2024-04-13 17:39:11 +00:00
Adding or configuring a new machine requires two simple steps:
2024-04-13 15:46:07 +00:00
### Step 1. Identify Target Disk-ID
1. Find the remote disk id by executing:
```bash title="setup computer"
2024-05-10 13:39:46 +00:00
ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
2024-04-13 15:46:07 +00:00
```
2024-05-14 14:13:50 +00:00
!!! Note
Replace `flash-installer.local` with the IP address of the machine if you don't have the avahi service running which resolves mDNS local domains.
2024-04-13 15:46:07 +00:00
Which should show something like:
2024-05-24 10:37:27 +00:00
```{.shellSession hl_lines="6" .no-copy}
2024-04-13 15:46:07 +00:00
NAME ID-LINK FSTYPE SIZE MOUNTPOINT
2024-06-15 20:27:37 +00:00
sda usb-ST_16GB_AA6271026J1000000509-0:0 14.9G
├─sda1 usb-ST_16GB_AA6271026J1000000509-0:0-part1 1M
2024-04-13 15:46:07 +00:00
├─sda2 usb-ST_16GB_AA6271026J1000000509-0:0-part2 vfat 100M /boot
└─sda3 usb-ST_16GB_AA6271026J1000000509-0:0-part3 ext4 2.9G /
2024-06-15 20:27:37 +00:00
nvme0n1 nvme-eui.e8238fa6bf530001001b448b4aec2929 476.9G
├─nvme0n1p1 nvme-eui.e8238fa6bf530001001b448b4aec2929-part1 vfat 512M
├─nvme0n1p2 nvme-eui.e8238fa6bf530001001b448b4aec2929-part2 ext4 459.6G
2024-04-13 15:46:07 +00:00
└─nvme0n1p3 nvme-eui.e8238fa6bf530001001b448b4aec2929-part3 swap 16.8G
```
2024-04-14 13:00:41 +00:00
1. Edit the following fields inside the `flake.nix`
2024-04-13 15:46:07 +00:00
2024-04-16 10:02:22 +00:00
=== "**buildClan**"
2024-05-12 21:38:37 +00:00
```nix title="clan-core.lib.buildClan" hl_lines="18 23"
2024-04-16 10:02:22 +00:00
buildClan {
2024-04-13 15:46:07 +00:00
# ...
2024-04-16 10:02:22 +00:00
machines = {
"jon" = {
2024-04-30 17:16:13 +00:00
imports = [
# ...
./modules/disko.nix
2024-05-12 21:09:08 +00:00
./machines/jon/configuration.nix
2024-04-30 17:16:13 +00:00
];
2024-04-16 10:02:22 +00:00
# ...
# Change this to the correct ip-address or hostname
# The hostname is the machine name by default
2024-05-10 20:59:45 +00:00
clan.networking.targetHost = pkgs.lib.mkDefault "root@jon"
2024-04-16 10:02:22 +00:00
# Change this to the ID-LINK of the desired disk shown by 'lsblk'
2024-04-30 17:16:13 +00:00
disko.devices.disk.main = {
2024-04-16 10:02:22 +00:00
device = "/dev/disk/by-id/__CHANGE_ME__";
}
2024-04-13 15:46:07 +00:00
2024-05-12 21:09:08 +00:00
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = [
"< YOUR SSH_KEY > "
];
2024-04-16 10:02:22 +00:00
# ...
};
2024-05-10 20:59:45 +00:00
};
2024-04-16 10:02:22 +00:00
}
```
2024-04-13 15:46:07 +00:00
2024-04-16 10:02:22 +00:00
=== "**flakeParts**"
2024-05-12 21:38:37 +00:00
```nix title="clan-core.flakeModules.default" hl_lines="18 23"
2024-04-16 10:02:22 +00:00
clan = {
2024-04-13 15:46:07 +00:00
# ...
2024-04-16 10:02:22 +00:00
machines = {
"jon" = {
2024-04-30 17:16:13 +00:00
imports = [
# ...
./modules/disko.nix
2024-05-12 21:09:08 +00:00
./machines/jon/configuration.nix
2024-04-30 17:16:13 +00:00
];
2024-04-16 10:02:22 +00:00
# ...
# Change this to the correct ip-address or hostname
# The hostname is the machine name by default
2024-05-10 20:59:45 +00:00
clan.networking.targetHost = pkgs.lib.mkDefault "root@jon"
2024-04-16 10:02:22 +00:00
# Change this to the ID-LINK of the desired disk shown by 'lsblk'
2024-04-30 17:16:13 +00:00
disko.devices.disk.main = {
2024-04-16 10:02:22 +00:00
device = "/dev/disk/by-id/__CHANGE_ME__";
}
2024-05-12 21:09:08 +00:00
# e.g. > cat ~/.ssh/id_ed25519.pub
users.users.root.openssh.authorizedKeys.keys = [
"__YOUR_SSH_KEY__"
];
2024-04-16 10:02:22 +00:00
# ...
};
2024-05-10 20:59:45 +00:00
};
2024-04-13 15:46:07 +00:00
};
2024-04-16 10:02:22 +00:00
```
2024-04-13 15:46:07 +00:00
2024-05-12 21:09:08 +00:00
!!! Info "Replace `__CHANGE_ME__` with the appropriate identifier, such as `nvme-eui.e8238fa6bf530001001b448b4aec2929` "
!!! Info "Replace `__YOUR_SSH_KEY__` with your personal key, like `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILoMI0NC5eT9pHlQExrvR5ASV3iW9+BXwhfchq0smXUJ jon@jon-desktop` "
2024-05-10 20:59:45 +00:00
2024-05-12 21:09:08 +00:00
These steps will allow you to update your machine later.
2024-05-07 19:26:15 +00:00
2024-05-14 16:20:56 +00:00
### Step 2: Detect Drivers
Generate the `hardware-configuration.nix` file for your machine by executing the following command:
2024-04-13 15:46:07 +00:00
2024-05-14 14:13:50 +00:00
```bash
2024-06-15 20:27:37 +00:00
clan machines hw-generate [MACHINE_NAME] [HOSTNAME]
2024-05-14 14:13:50 +00:00
```
2024-06-15 20:27:37 +00:00
replace `[MACHINE_NAME]` with the name of the machine i.e. `jon` and `[HOSTNAME]` with the `ip_adress` or `hostname` of the machine within the network. i.e. `flash-installer.local`
!!! Example
```bash
clan machines hw-generate jon flash-installer.local
```
This command connects to `flash-installer.local` as `root` , runs `nixos-generate-config` to detect hardware configurations (excluding filesystems), and writes them to `machines/jon/hardware-configuration.nix` .
2024-05-14 16:20:56 +00:00
### Step 3: Custom Disk Formatting
In `./modules/disko.nix` , a simple `ext4` disk partitioning scheme is defined for the Disko module. For more complex disk partitioning setups, refer to the [Disko examples ](https://github.com/nix-community/disko/tree/master/example ).
### Step 4: Custom Configuration
Modify `./machines/jon/configuration.nix` to personalize the system settings according to your requirements.
### Step 5: Check Configuration
Validate your configuration by running:
```bash
nix flake check
```
2024-05-14 14:13:50 +00:00
2024-05-14 16:20:56 +00:00
This command helps ensure that your system configuration is correct and free from errors.
2024-05-14 14:13:50 +00:00
2024-05-14 16:20:56 +00:00
!!! Note
2024-04-13 15:46:07 +00:00
2024-05-14 16:20:56 +00:00
Integrate this step into your [Continuous Integration ](https://en.wikipedia.org/wiki/Continuous_integration ) workflow to ensure that only valid Nix configurations are merged into your codebase. This practice helps maintain system stability and reduces integration issues.
2024-05-12 21:09:08 +00:00
2024-04-26 09:07:33 +00:00
---
## Whats next?
2024-05-10 20:59:45 +00:00
- [Secrets & Facts ](secrets.md ): Setting up secrets with nix-sops
2024-04-26 09:07:33 +00:00
---