diff options
Diffstat (limited to 'hosts/vidhar/network/dhcp')
| -rw-r--r-- | hosts/vidhar/network/dhcp/default.nix | 137 | ||||
| -rw-r--r-- | hosts/vidhar/network/dhcp/knot-tsig (renamed from hosts/vidhar/network/dhcp/knot-tsig.json.frag) | 18 |
2 files changed, 42 insertions, 113 deletions
diff --git a/hosts/vidhar/network/dhcp/default.nix b/hosts/vidhar/network/dhcp/default.nix index 11460393..2efabd23 100644 --- a/hosts/vidhar/network/dhcp/default.nix +++ b/hosts/vidhar/network/dhcp/default.nix | |||
| @@ -48,12 +48,6 @@ in { | |||
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | client-classes = [ | 50 | client-classes = [ |
| 51 | { name = "ipxe-eostre"; | ||
| 52 | test = "hexstring(pkt4.mac, ':') == '00:d8:61:79:c5:40' and option[77].hex == 'iPXE-yggdrasil'"; | ||
| 53 | next-server = tftpIp; | ||
| 54 | boot-file-name = "${nfsrootBaseUrl}/eostre.menu.ipxe"; | ||
| 55 | only-if-required = true; | ||
| 56 | } | ||
| 57 | { name = "ipxe-yggdrasil"; | 51 | { name = "ipxe-yggdrasil"; |
| 58 | test = "option[77].hex == 'iPXE-yggdrasil'"; | 52 | test = "option[77].hex == 'iPXE-yggdrasil'"; |
| 59 | next-server = tftpIp; | 53 | next-server = tftpIp; |
| @@ -256,40 +250,27 @@ in { | |||
| 256 | } | 250 | } |
| 257 | ]; | 251 | ]; |
| 258 | }; | 252 | }; |
| 253 | tsig-keys = [ | ||
| 254 | { name = "local_key"; | ||
| 255 | algorithm = "HMAC-SHA256"; | ||
| 256 | secret-file = "/run/credentials/kea-dhcp-ddns-server.service/local_key"; | ||
| 257 | } | ||
| 258 | ]; | ||
| 259 | }; | 259 | }; |
| 260 | }; | 260 | }; |
| 261 | }; | 261 | }; |
| 262 | 262 | ||
| 263 | systemd.services.kea-dhcp-ddns-server = { | 263 | systemd.services.kea-dhcp-ddns-server = { |
| 264 | preStart = let | ||
| 265 | configLines = [ | ||
| 266 | "<?include \"\${CREDENTIALS_DIRECTORY}/knot-tsig.json.frag\"?>" | ||
| 267 | ] ++ mapAttrsToList (k: v: | ||
| 268 | "\"${k}\": ${builtins.toJSON v}" | ||
| 269 | ) config.services.kea.dhcp-ddns.settings; | ||
| 270 | |||
| 271 | config-template = pkgs.writeText "dhcp-ddns.conf" '' | ||
| 272 | {"DhcpDdns": { | ||
| 273 | ${concatStringsSep ",\n " configLines} | ||
| 274 | }} | ||
| 275 | ''; | ||
| 276 | in '' | ||
| 277 | ${pkgs.envsubst}/bin/envsubst -i "${config-template}" -o "''${RUNTIME_DIRECTORY}/dhcp-ddns.conf" | ||
| 278 | ''; | ||
| 279 | |||
| 280 | serviceConfig = { | 264 | serviceConfig = { |
| 281 | ExecStart = mkForce '' | ||
| 282 | ${pkgs.kea}/bin/kea-dhcp-ddns -c "''${RUNTIME_DIRECTORY}/dhcp-ddns.conf" ${escapeShellArgs config.services.kea.dhcp-ddns.extraArgs} | ||
| 283 | ''; | ||
| 284 | LoadCredential = [ | 265 | LoadCredential = [ |
| 285 | "knot-tsig.json.frag:${config.sops.secrets."kea-knot-tsig.json.frag".path}" | 266 | "local_key:${config.sops.secrets."kea-knot-tsig".path}" |
| 286 | ]; | 267 | ]; |
| 287 | }; | 268 | }; |
| 288 | }; | 269 | }; |
| 289 | 270 | ||
| 290 | sops.secrets."kea-knot-tsig.json.frag" = { | 271 | sops.secrets."kea-knot-tsig" = { |
| 291 | format = "binary"; | 272 | format = "binary"; |
| 292 | sopsFile = ./knot-tsig.json.frag; | 273 | sopsFile = ./knot-tsig; |
| 293 | }; | 274 | }; |
| 294 | 275 | ||
| 295 | services.nginx.virtualHosts."nfsroot.vidhar.yggdrasil" = { | 276 | services.nginx.virtualHosts."nfsroot.vidhar.yggdrasil" = { |
| @@ -307,49 +288,52 @@ in { | |||
| 307 | name = "installer-${system}"; | 288 | name = "installer-${system}"; |
| 308 | paths = [ | 289 | paths = [ |
| 309 | (builtins.addErrorContext "while evaluating installer-${system}-nfsroot" (let | 290 | (builtins.addErrorContext "while evaluating installer-${system}-nfsroot" (let |
| 310 | installerBuild' = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { | 291 | # installerBuild' = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { |
| 311 | modules = [ | 292 | # modules = [ |
| 312 | ({ ... }: { | 293 | # ({ ... }: { |
| 313 | config.nfsroot.storeDevice = "${nfsIp}:nix-store"; | 294 | # config.nfsroot.storeDevice = "${nfsIp}:nix-store"; |
| 314 | config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/installer-${system}/registration"; | 295 | # config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/installer-${system}/registration"; |
| 315 | config.system.nixos.label = "installer-${system}"; | 296 | # config.system.nixos.label = "installer-${system}"; |
| 316 | }) | 297 | # }) |
| 317 | ]; | 298 | # ]; |
| 318 | }); | 299 | # }); |
| 319 | installerBuild = installerBuild'.config.system.build; | 300 | # installerBuild = installerBuild'.config.system.build; |
| 301 | |||
| 302 | # install -m 0444 -t $out/installer-${system} \ | ||
| 303 | # ${installerBuild.initialRamdisk}/initrd \ | ||
| 304 | # ${installerBuild.kernel}/bzImage \ | ||
| 305 | # ${installerBuild.netbootIpxeScript}/netboot.ipxe \ | ||
| 306 | # ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration | ||
| 307 | |||
| 308 | # item installer ${with installerBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"} | ||
| 309 | |||
| 310 | # :installer | ||
| 311 | # chain installer-${system}/netboot.ipxe | ||
| 312 | # goto start | ||
| 313 | |||
| 320 | in builtins.toPath (pkgs.runCommandLocal "installer-${system}" {} '' | 314 | in builtins.toPath (pkgs.runCommandLocal "installer-${system}" {} '' |
| 321 | mkdir -p $out/installer-${system} | 315 | mkdir -p $out/installer-${system} |
| 322 | install -m 0444 -t $out/installer-${system} \ | ||
| 323 | ${installerBuild.initialRamdisk}/initrd \ | ||
| 324 | ${installerBuild.kernel}/bzImage \ | ||
| 325 | ${installerBuild.netbootIpxeScript}/netboot.ipxe \ | ||
| 326 | ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration | ||
| 327 | install -m 0444 ${pkgs.writeText "installer-${system}.menu.ipxe" '' | 316 | install -m 0444 ${pkgs.writeText "installer-${system}.menu.ipxe" '' |
| 328 | #!ipxe | 317 | #!ipxe |
| 329 | 318 | ||
| 330 | :start | 319 | :start |
| 331 | menu iPXE boot menu for installer-${system} | 320 | menu iPXE boot menu for installer-${system} |
| 332 | item installer ${with installerBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"} | ||
| 333 | item memtest memtest86plus | 321 | item memtest memtest86plus |
| 334 | item netboot netboot.xyz | 322 | item netboot netboot.xyz |
| 335 | item shell iPXE shell | 323 | item shell iPXE shell |
| 336 | choose --timeout 0 --default installer selected || goto shell | 324 | choose --timeout 0 --default netboot selected || goto shell |
| 337 | goto ''${selected} | 325 | goto ''${selected} |
| 338 | 326 | ||
| 339 | :shell | 327 | :shell |
| 340 | shell | 328 | shell |
| 341 | goto start | 329 | goto start |
| 342 | 330 | ||
| 343 | :installer | ||
| 344 | chain installer-${system}/netboot.ipxe | ||
| 345 | goto start | ||
| 346 | |||
| 347 | :netboot | 331 | :netboot |
| 348 | iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn | 332 | iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn |
| 349 | goto start | 333 | goto start |
| 350 | 334 | ||
| 351 | :memtest | 335 | :memtest |
| 352 | iseq ''${platform} efi && chain --autofree memtest.efi || chain --autofree memtest.bin | 336 | chain --autofree mt86plus.efi |
| 353 | goto start | 337 | goto start |
| 354 | ''} $out/installer-${system}.menu.ipxe | 338 | ''} $out/installer-${system}.menu.ipxe |
| 355 | ''))) | 339 | ''))) |
| @@ -360,61 +344,10 @@ in { | |||
| 360 | mkdir $out | 344 | mkdir $out |
| 361 | install -m 0444 -t $out \ | 345 | install -m 0444 -t $out \ |
| 362 | ${ipxe}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} \ | 346 | ${ipxe}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} \ |
| 363 | ${pkgs.memtest86plus}/{memtest.efi,memtest.bin} | 347 | ${pkgs.memtest86plus}/mt86plus.efi |
| 364 | install -m 0444 ${sources.netbootxyz-efi.src} $out/netboot.xyz.efi | 348 | install -m 0444 ${sources.netbootxyz-efi.src} $out/netboot.xyz.efi |
| 365 | install -m 0444 ${sources.netbootxyz-lkrn.src} $out/netboot.xyz.lkrn | 349 | install -m 0444 ${sources.netbootxyz-lkrn.src} $out/netboot.xyz.lkrn |
| 366 | '') | 350 | '') |
| 367 | (builtins.addErrorContext "while evaluating eostre" (let | ||
| 368 | eostreBuild' = (flake.nixosConfigurations.eostre.extendModules { | ||
| 369 | modules = [ | ||
| 370 | ({ ... }: { | ||
| 371 | config.nfsroot.storeDevice = "${nfsIp}:nix-store"; | ||
| 372 | config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/eostre/registration"; | ||
| 373 | config.system.nixos.label = "eostre"; | ||
| 374 | }) | ||
| 375 | ]; | ||
| 376 | }); | ||
| 377 | eostreBuild = eostreBuild'.config.system.build; | ||
| 378 | in builtins.toPath (pkgs.runCommandLocal "eostre" {} '' | ||
| 379 | mkdir -p $out/eostre | ||
| 380 | install -m 0444 -t $out/eostre \ | ||
| 381 | ${eostreBuild.initialRamdisk}/initrd \ | ||
| 382 | ${eostreBuild.kernel}/bzImage \ | ||
| 383 | ${eostreBuild.netbootIpxeScript}/netboot.ipxe \ | ||
| 384 | ${pkgs.closureInfo { rootPaths = eostreBuild.storeContents; }}/registration | ||
| 385 | install -m 0444 ${pkgs.writeText "eostre.menu.ipxe" '' | ||
| 386 | #!ipxe | ||
| 387 | |||
| 388 | set menu-timeout 5000 | ||
| 389 | |||
| 390 | :start | ||
| 391 | menu iPXE boot menu for eostre | ||
| 392 | item eostre ${with eostreBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"} | ||
| 393 | item memtest memtest86plus | ||
| 394 | item netboot netboot.xyz | ||
| 395 | item shell iPXE shell | ||
| 396 | choose --timeout ''${menu-timeout} --default eostre selected || goto shell | ||
| 397 | set menu-timeout 0 | ||
| 398 | goto ''${selected} | ||
| 399 | |||
| 400 | :shell | ||
| 401 | set menu-timeout 0 | ||
| 402 | shell | ||
| 403 | goto start | ||
| 404 | |||
| 405 | :eostre | ||
| 406 | chain eostre/netboot.ipxe | ||
| 407 | goto start | ||
| 408 | |||
| 409 | :netboot | ||
| 410 | iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn | ||
| 411 | goto start | ||
| 412 | |||
| 413 | :memtest | ||
| 414 | iseq ''${platform} efi && chain --autofree memtest.efi || chain --autofree memtest.bin | ||
| 415 | goto start | ||
| 416 | ''} $out/eostre.menu.ipxe | ||
| 417 | ''))) | ||
| 418 | ]; | 351 | ]; |
| 419 | }; | 352 | }; |
| 420 | }; | 353 | }; |
diff --git a/hosts/vidhar/network/dhcp/knot-tsig.json.frag b/hosts/vidhar/network/dhcp/knot-tsig index c10115cf..73a8f11d 100644 --- a/hosts/vidhar/network/dhcp/knot-tsig.json.frag +++ b/hosts/vidhar/network/dhcp/knot-tsig | |||
| @@ -1,18 +1,14 @@ | |||
| 1 | { | 1 | { |
| 2 | "data": "ENC[AES256_GCM,data:cGcoqYZ341xQOFukDm4J5KDfG6+NaNbk2U2k4YGneRsAoPJZe/8KDmVr8TBWFCXXbuzeCGbiuXRVBmtYSEIqbqTN4u00RdQgpeL72cB3ZFd2c7cideEQV5z802pqFfXSlmLBC01OPG3TwAgk6xhQYSn5IcBTIL6fRF235Y9Q8k/X96rhfwPRVq84,iv:UoweWBcVuQIXeWFFl/WNUHLXG8nEri1UuTskC2I26hU=,tag:TJldVr2LDTmKA3ozZoX+cQ==,type:str]", | 2 | "data": "ENC[AES256_GCM,data:ZjPqKfUCRYD4iD7yC7qObZhBAMll0DXNzImZ43TM0D8SXRtANqG6YnfwQuJ7,iv:GXD5LutgEz6ktGEtpI9z41IJLLzIMj6OvPADQlZcvwk=,tag:v9ISQFDubtLWcb2mVHa4zA==,type:str]", |
| 3 | "sops": { | 3 | "sops": { |
| 4 | "kms": null, | ||
| 5 | "gcp_kms": null, | ||
| 6 | "azure_kv": null, | ||
| 7 | "hc_vault": null, | ||
| 8 | "age": [ | 4 | "age": [ |
| 9 | { | 5 | { |
| 10 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | 6 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBCYk5tM1lPRXc0MGpHZENQ\ndDU2M2VKY2t2VGFrcTUvd0NrU3VMZGQ3NHlNClNTaWVjdDNTQXh6WDFmMDk3SWtn\ncjJjRzUxODFFL25Ic0dabyt1ZW5xRE0KLS0tIDJlT0NTVDlXNWphQ1B0VTQ1U0NH\nNktRNlIrQzdhRjZ0SjR0T3oyRkZiWXMKX28S4SySQguT1cgMZpDY4o/OKY6IvjT9\n1oUzwx/BzBbC2JbpGYvQQgp/qfiM2k0oXmQlfdTv8kD/MoOqPO8E1Q==\n-----END AGE ENCRYPTED FILE-----\n", |
| 11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBCYk5tM1lPRXc0MGpHZENQ\ndDU2M2VKY2t2VGFrcTUvd0NrU3VMZGQ3NHlNClNTaWVjdDNTQXh6WDFmMDk3SWtn\ncjJjRzUxODFFL25Ic0dabyt1ZW5xRE0KLS0tIDJlT0NTVDlXNWphQ1B0VTQ1U0NH\nNktRNlIrQzdhRjZ0SjR0T3oyRkZiWXMKX28S4SySQguT1cgMZpDY4o/OKY6IvjT9\n1oUzwx/BzBbC2JbpGYvQQgp/qfiM2k0oXmQlfdTv8kD/MoOqPO8E1Q==\n-----END AGE ENCRYPTED FILE-----\n" | 7 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l" |
| 12 | } | 8 | } |
| 13 | ], | 9 | ], |
| 14 | "lastmodified": "2022-03-15T13:52:17Z", | 10 | "lastmodified": "2026-07-29T06:39:18Z", |
| 15 | "mac": "ENC[AES256_GCM,data:rTelaGx5S2E2oYPNGfctFbgDKdyRX8tpVTqLtpcCAJ8MS5ppFTjnSwYi4yQHvTicfAPNz7hGJYAnTdyC2QDTciJgkS6KC3CCXWCimkTybBdVW4Azwz9iBZCpWu+rB1vcQhSLlLCaKmKskkqDZZ5+mfuaXc+TT2uwTA0SDtZWvnM=,iv:ANCZ1fHy6w/svEE53o7rWsp5qU15qoriqyVMzClH6J0=,tag:H92RM5GuLIl9/kslq4tzkQ==,type:str]", | 11 | "mac": "ENC[AES256_GCM,data:hj/YR0N8NhGHQEcCOjt/r+rfM8plkaUZoee9sI25evvEvOlfX69YRxUv1vyd6Sqd9wPEgCsF5STnMXFQhq3zgGjoTFcdHU+olRVmRq9rkYQo/ButZ/NEIQ7uc5b4FRPdPwOGF14aSpgI67F35oRavv1vtk10zGme+X0I1VXTIqE=,iv:rMUL+CyTLhQBJrsQJQPhN75FjCf5uGFh1z6KAXKDeB8=,tag:bpeQZ3UPZ10tCrgveoDklg==,type:str]", |
| 16 | "pgp": [ | 12 | "pgp": [ |
| 17 | { | 13 | { |
| 18 | "created_at": "2023-01-30T11:00:34Z", | 14 | "created_at": "2023-01-30T11:00:34Z", |
| @@ -21,6 +17,6 @@ | |||
| 21 | } | 17 | } |
| 22 | ], | 18 | ], |
| 23 | "unencrypted_suffix": "_unencrypted", | 19 | "unencrypted_suffix": "_unencrypted", |
| 24 | "version": "3.7.1" | 20 | "version": "3.13.2" |
| 25 | } | 21 | } |
| 26 | } \ No newline at end of file | 22 | } |
