summaryrefslogtreecommitdiff
path: root/hosts/vidhar/network/dhcp
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vidhar/network/dhcp')
-rw-r--r--hosts/vidhar/network/dhcp/default.nix164
-rw-r--r--hosts/vidhar/network/dhcp/knot-tsig (renamed from hosts/vidhar/network/dhcp/knot-tsig.json.frag)18
2 files changed, 81 insertions, 101 deletions
diff --git a/hosts/vidhar/network/dhcp/default.nix b/hosts/vidhar/network/dhcp/default.nix
index f36d0c7f..e4c3f16e 100644
--- a/hosts/vidhar/network/dhcp/default.nix
+++ b/hosts/vidhar/network/dhcp/default.nix
@@ -5,6 +5,7 @@ with lib;
5let 5let
6 nfsrootBaseUrl = "http://nfsroot.vidhar.yggdrasil"; 6 nfsrootBaseUrl = "http://nfsroot.vidhar.yggdrasil";
7 tftpIp = "10.141.0.1"; 7 tftpIp = "10.141.0.1";
8 nfsIp = tftpIp;
8 ipxe = pkgs.ipxe.override { 9 ipxe = pkgs.ipxe.override {
9 additionalTargets = { 10 additionalTargets = {
10 "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; 11 "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi";
@@ -47,12 +48,12 @@ in {
47 }; 48 };
48 49
49 client-classes = [ 50 client-classes = [
50 { name = "ipxe-eostre"; 51 # { name = "ipxe-eostre";
51 test = "hexstring(pkt4.mac, ':') == '00:d8:61:79:c5:40' and option[77].hex == 'iPXE-yggdrasil'"; 52 # test = "hexstring(pkt4.mac, ':') == '00:d8:61:79:c5:40' and option[77].hex == 'iPXE-yggdrasil'";
52 next-server = tftpIp; 53 # next-server = tftpIp;
53 boot-file-name = "${nfsrootBaseUrl}/eostre.menu.ipxe"; 54 # boot-file-name = "${nfsrootBaseUrl}/eostre.menu.ipxe";
54 only-if-required = true; 55 # only-if-required = true;
55 } 56 # }
56 { name = "ipxe-yggdrasil"; 57 { name = "ipxe-yggdrasil";
57 test = "option[77].hex == 'iPXE-yggdrasil'"; 58 test = "option[77].hex == 'iPXE-yggdrasil'";
58 next-server = tftpIp; 59 next-server = tftpIp;
@@ -255,40 +256,27 @@ in {
255 } 256 }
256 ]; 257 ];
257 }; 258 };
259 tsig-keys = [
260 { name = "local_key";
261 algorithm = "HMAC-SHA256";
262 secret-file = "/run/credentials/kea-dhcp-ddns-server.service/local_key";
263 }
264 ];
258 }; 265 };
259 }; 266 };
260 }; 267 };
261 268
262 systemd.services.kea-dhcp-ddns-server = { 269 systemd.services.kea-dhcp-ddns-server = {
263 preStart = let
264 configLines = [
265 "<?include \"\${CREDENTIALS_DIRECTORY}/knot-tsig.json.frag\"?>"
266 ] ++ mapAttrsToList (k: v:
267 "\"${k}\": ${builtins.toJSON v}"
268 ) config.services.kea.dhcp-ddns.settings;
269
270 config-template = pkgs.writeText "dhcp-ddns.conf" ''
271 {"DhcpDdns": {
272 ${concatStringsSep ",\n " configLines}
273 }}
274 '';
275 in ''
276 ${pkgs.envsubst}/bin/envsubst -i "${config-template}" -o "''${RUNTIME_DIRECTORY}/dhcp-ddns.conf"
277 '';
278
279 serviceConfig = { 270 serviceConfig = {
280 ExecStart = mkForce ''
281 ${pkgs.kea}/bin/kea-dhcp-ddns -c "''${RUNTIME_DIRECTORY}/dhcp-ddns.conf" ${escapeShellArgs config.services.kea.dhcp-ddns.extraArgs}
282 '';
283 LoadCredential = [ 271 LoadCredential = [
284 "knot-tsig.json.frag:${config.sops.secrets."kea-knot-tsig.json.frag".path}" 272 "local_key:${config.sops.secrets."kea-knot-tsig".path}"
285 ]; 273 ];
286 }; 274 };
287 }; 275 };
288 276
289 sops.secrets."kea-knot-tsig.json.frag" = { 277 sops.secrets."kea-knot-tsig" = {
290 format = "binary"; 278 format = "binary";
291 sopsFile = ./knot-tsig.json.frag; 279 sopsFile = ./knot-tsig;
292 }; 280 };
293 281
294 services.nginx.virtualHosts."nfsroot.vidhar.yggdrasil" = { 282 services.nginx.virtualHosts."nfsroot.vidhar.yggdrasil" = {
@@ -305,32 +293,30 @@ in {
305 pkgs.symlinkJoin { 293 pkgs.symlinkJoin {
306 name = "installer-${system}"; 294 name = "installer-${system}";
307 paths = [ 295 paths = [
308 (let 296 (builtins.addErrorContext "while evaluating installer-${system}-nfsroot" (let
309 installerBuild = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { 297 installerBuild' = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules {
310 modules = [ 298 modules = [
311 ({ ... }: { 299 ({ ... }: {
312 config.nfsroot.storeDevice = "${tftpIp}:nix-store"; 300 config.nfsroot.storeDevice = "${nfsIp}:nix-store";
313 config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/installer-${system}/registration"; 301 config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/installer-${system}/registration";
302 config.system.nixos.label = "installer-${system}";
314 }) 303 })
315 ]; 304 ];
316 }).config.system.build; 305 });
317 in builtins.toPath (pkgs.runCommandLocal "install-${system}" {} '' 306 installerBuild = installerBuild'.config.system.build;
307 in builtins.toPath (pkgs.runCommandLocal "installer-${system}" {} ''
318 mkdir -p $out/installer-${system} 308 mkdir -p $out/installer-${system}
319 install -m 0444 -t $out/installer-${system} \ 309 install -m 0444 -t $out/installer-${system} \
320 ${installerBuild.initialRamdisk}/initrd \ 310 ${installerBuild.initialRamdisk}/initrd \
321 ${installerBuild.kernel}/bzImage \ 311 ${installerBuild.kernel}/bzImage \
322 ${installerBuild.netbootIpxeScript}/netboot.ipxe \ 312 ${installerBuild.netbootIpxeScript}/netboot.ipxe \
323 ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration 313 ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration
324 '')) 314 install -m 0444 ${pkgs.writeText "installer-${system}.menu.ipxe" ''
325 (pkgs.writeTextFile {
326 name = "installer-${system}.menu.ipxe";
327 destination = "/installer-${system}.menu.ipxe";
328 text = ''
329 #!ipxe 315 #!ipxe
330 316
331 :start 317 :start
332 menu iPXE boot menu for installer-${system} 318 menu iPXE boot menu for installer-${system}
333 item installer installer-${system} 319 item installer ${with installerBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"}
334 item memtest memtest86plus 320 item memtest memtest86plus
335 item netboot netboot.xyz 321 item netboot netboot.xyz
336 item shell iPXE shell 322 item shell iPXE shell
@@ -350,10 +336,10 @@ in {
350 goto start 336 goto start
351 337
352 :memtest 338 :memtest
353 iseq ''${platform} efi && chain --autofree memtest.efi || chain --autofree memtest.bin 339 chain --autofree mt86plus.efi
354 goto start 340 goto start
355 ''; 341 ''} $out/installer-${system}.menu.ipxe
356 }) 342 '')))
357 ]; 343 ];
358 }) ["x86_64-linux"] 344 }) ["x86_64-linux"]
359 ) ++ [ 345 ) ++ [
@@ -361,63 +347,61 @@ in {
361 mkdir $out 347 mkdir $out
362 install -m 0444 -t $out \ 348 install -m 0444 -t $out \
363 ${ipxe}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} \ 349 ${ipxe}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} \
364 ${pkgs.memtest86plus}/{memtest.efi,memtest.bin} 350 ${pkgs.memtest86plus}/mt86plus.efi
365 install -m 0444 ${sources.netbootxyz-efi.src} $out/netboot.xyz.efi 351 install -m 0444 ${sources.netbootxyz-efi.src} $out/netboot.xyz.efi
366 install -m 0444 ${sources.netbootxyz-lkrn.src} $out/netboot.xyz.lkrn 352 install -m 0444 ${sources.netbootxyz-lkrn.src} $out/netboot.xyz.lkrn
367 '') 353 '')
368 (let 354 # (builtins.addErrorContext "while evaluating eostre" (let
369 eostreBuild = (flake.nixosConfigurations.eostre.extendModules { 355 # eostreBuild' = (flake.nixosConfigurations.eostre.extendModules {
370 modules = [ 356 # modules = [
371 ({ ... }: { 357 # ({ ... }: {
372 config.nfsroot.storeDevice = "${tftpIp}:nix-store"; 358 # config.nfsroot.storeDevice = "${nfsIp}:nix-store";
373 config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/eostre/registration"; 359 # config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/eostre/registration";
374 }) 360 # config.system.nixos.label = "eostre";
375 ]; 361 # })
376 }).config.system.build; 362 # ];
377 in builtins.toPath (pkgs.runCommandLocal "eostre" {} '' 363 # });
378 mkdir -p $out/eostre 364 # eostreBuild = eostreBuild'.config.system.build;
379 install -m 0444 -t $out/eostre \ 365 # in builtins.toPath (pkgs.runCommandLocal "eostre" {} ''
380 ${eostreBuild.initialRamdisk}/initrd \ 366 # mkdir -p $out/eostre
381 ${eostreBuild.kernel}/bzImage \ 367 # install -m 0444 -t $out/eostre \
382 ${eostreBuild.netbootIpxeScript}/netboot.ipxe \ 368 # ${eostreBuild.initialRamdisk}/initrd \
383 ${pkgs.closureInfo { rootPaths = eostreBuild.storeContents; }}/registration 369 # ${eostreBuild.kernel}/bzImage \
384 '')) 370 # ${eostreBuild.netbootIpxeScript}/netboot.ipxe \
385 (pkgs.writeTextFile { 371 # ${pkgs.closureInfo { rootPaths = eostreBuild.storeContents; }}/registration
386 name = "eostre.menu.ipxe"; 372 # install -m 0444 ${pkgs.writeText "eostre.menu.ipxe" ''
387 destination = "/eostre.menu.ipxe"; 373 # #!ipxe
388 text = ''
389 #!ipxe
390 374
391 set menu-timeout 5000 375 # set menu-timeout 5000
392 376
393 :start 377 # :start
394 menu iPXE boot menu for eostre 378 # menu iPXE boot menu for eostre
395 item eostre eostre 379 # item eostre ${with eostreBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"}
396 item memtest memtest86plus 380 # item memtest memtest86plus
397 item netboot netboot.xyz 381 # item netboot netboot.xyz
398 item shell iPXE shell 382 # item shell iPXE shell
399 choose --timeout ''${menu-timeout} --default eostre selected || goto shell 383 # choose --timeout ''${menu-timeout} --default eostre selected || goto shell
400 set menu-timeout 0 384 # set menu-timeout 0
401 goto ''${selected} 385 # goto ''${selected}
402 386
403 :shell 387 # :shell
404 set menu-timeout 0 388 # set menu-timeout 0
405 shell 389 # shell
406 goto start 390 # goto start
407 391
408 :eostre 392 # :eostre
409 chain eostre/netboot.ipxe 393 # chain eostre/netboot.ipxe
410 goto start 394 # goto start
411 395
412 :netboot 396 # :netboot
413 iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn 397 # iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn
414 goto start 398 # goto start
415 399
416 :memtest 400 # :memtest
417 iseq ''${platform} efi && chain --autofree memtest.efi || chain --autofree memtest.bin 401 # chain --autofree mt86plus.efi
418 goto start 402 # goto start
419 ''; 403 # ''} $out/eostre.menu.ipxe
420 }) 404 # '')))
421 ]; 405 ];
422 }; 406 };
423 }; 407 };
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}