Nix configurations for my homelab
1{ config, lib, ... }:
2{
3 nix = {
4 buildMachines = [
5 (lib.mkIf (config.networking.hostName != "lily") {
6 hostName = "nixremote-lily";
7 system = "x86_64-linux";
8 maxJobs = 1;
9 speedFactor = 2;
10 supportedFeatures = [
11 "benchmark"
12 "big-parallel"
13 "kvm"
14 "nixos-test"
15 ];
16 protocol = "ssh-ng";
17 })
18 (lib.mkIf (config.networking.hostName != "lutea") {
19 hostName = "nixremote-lutea";
20 system = "x86_64-linux";
21 maxJobs = 1;
22 speedFactor = 3;
23 supportedFeatures = [
24 "benchmark"
25 "big-parallel"
26 "kvm"
27 "nixos-test"
28 ];
29 protocol = "ssh-ng";
30 })
31 ];
32 distributedBuilds = true;
33 };
34
35 programs.ssh = {
36 knownHosts = {
37 nixremote-lily = {
38 hostNames = [ config.garden.info.network.lily.netbird-ip ];
39 publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINaReNM+eSIzbZvqahaAlanf0z89rJQIYWx/rlaS4f1Y";
40 };
41 nixremote-lutea = {
42 hostNames = [ config.garden.info.network.lutea.netbird-ip ];
43 publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNMTxa2zRmHIXt3ARlCplboWRdCsAmDlN8gDLik4vNs";
44 };
45 };
46 extraConfig =
47 let
48 ifElseEmtpy = check: result: if check then result else "";
49 mkSshConfig =
50 host: ip:
51 ifElseEmtpy (config.networking.hostName != host) ''
52 Host nixremote-${host}
53 HostName ${ip}
54 Port 2222
55 User nixremote
56 IdentitiesOnly yes
57 IdentityFile /data/nixremote/id_ed25519
58 '';
59 in
60 ''
61 ${mkSshConfig "lily" config.garden.info.network.lily.netbird-ip}
62 ${mkSshConfig "lutea" config.garden.info.network.lutea.netbird-ip}
63 '';
64 };
65}