···139139home-manager switch --flake .#noah-aleister
140140```
141141142142+### Remote Builders
143143+144144+`shizuri` and `odin` are configured as trusted `x86_64-linux` Nix remote builders. Client hosts import `modules/nix-remote-builders.nix` through `common.nix`, so NixOS hosts in this flake will try to use both builders except for the current host itself.
145145+146146+Builder access uses the `nixremote` user declared in `modules/nix-builder.nix`. Add client public keys to `users.users.nixremote.openssh.authorizedKeys.keys` before rebuilding the build hosts.
147147+148148+#### Set up a new client
149149+150150+Generate or install the client key at the path expected by `modules/nix-remote-builders.nix`:
151151+152152+```bash
153153+sudo install -d -m 700 /root/.ssh
154154+sudo ssh-keygen -t ed25519 -N '' -C "nix-remote-builder@$(hostname)" -f /root/.ssh/nix-remote-builder
155155+```
156156+157157+Copy the public key:
158158+159159+```bash
160160+sudo cat /root/.ssh/nix-remote-builder.pub
161161+```
162162+163163+Add that public key to `users.users.nixremote.openssh.authorizedKeys.keys` in `modules/nix-builder.nix`, then rebuild each builder:
164164+165165+```bash
166166+sudo nixos-rebuild switch --flake .#shizuri
167167+sudo nixos-rebuild switch --flake .#odin
168168+```
169169+170170+On the client, trust the builder host keys and rebuild the client:
171171+172172+```bash
173173+sudo ssh-keyscan -H shizuri odin | sudo tee -a /root/.ssh/known_hosts >/dev/null
174174+sudo nixos-rebuild switch --flake .#<client-hostname>
175175+```
176176+177177+Test builder access:
178178+179179+```bash
180180+sudo ssh -i /root/.ssh/nix-remote-builder nixremote@shizuri nix-store --version
181181+sudo ssh -i /root/.ssh/nix-remote-builder nixremote@odin nix-store --version
182182+sudo nix build nixpkgs#hello --max-jobs 0 -L
183183+```
184184+185185+#### Set up a new build host
186186+187187+Import the builder module from the new host configuration:
188188+189189+```nix
190190+{
191191+ imports = [
192192+ ../../modules/nix-builder.nix
193193+ ];
194194+}
195195+```
196196+197197+Add the host to the `builders` list in `modules/nix-remote-builders.nix`:
198198+199199+```nix
200200+{
201201+ hostName = "new-builder";
202202+ sshUser = "nixremote";
203203+ sshKey = "/root/.ssh/nix-remote-builder";
204204+ system = "x86_64-linux";
205205+ protocol = "ssh-ng";
206206+ maxJobs = 24;
207207+ speedFactor = 4;
208208+ supportedFeatures = [
209209+ "nixos-test"
210210+ "benchmark"
211211+ "big-parallel"
212212+ "kvm"
213213+ ];
214214+}
215215+```
216216+217217+Rebuild the new builder first, then rebuild each client that should use it:
218218+219219+```bash
220220+sudo nixos-rebuild switch --flake .#new-builder
221221+sudo ssh-keyscan -H new-builder | sudo tee -a /root/.ssh/known_hosts >/dev/null
222222+sudo nixos-rebuild switch --flake .#<client-hostname>
223223+```
224224+142225## Maintenance
143226144227Regular maintenance tasks:
+4
common.nix
···11{ ... }:
22{
33+ imports = [
44+ ./modules/nix-remote-builders.nix
55+ ];
66+37 # Set your time zone.
48 time.timeZone = "America/Chicago";
59