diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-10-22 19:33:45 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-10-22 19:33:45 +0200 |
commit | ddcc8c65e30a9ca3b56e25466e749cb100b28510 (patch) | |
tree | 869c782c4e5874d4d353d3cd82af5b0e2dfe9a45 /hosts/vidhar/network/dhcp | |
parent | 0b7bd91465487426041c777a40de3be9f7407058 (diff) | |
download | nixos-ddcc8c65e30a9ca3b56e25466e749cb100b28510.tar nixos-ddcc8c65e30a9ca3b56e25466e749cb100b28510.tar.gz nixos-ddcc8c65e30a9ca3b56e25466e749cb100b28510.tar.bz2 nixos-ddcc8c65e30a9ca3b56e25466e749cb100b28510.tar.xz nixos-ddcc8c65e30a9ca3b56e25466e749cb100b28510.zip |
...
Diffstat (limited to 'hosts/vidhar/network/dhcp')
-rw-r--r-- | hosts/vidhar/network/dhcp/default.nix | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/hosts/vidhar/network/dhcp/default.nix b/hosts/vidhar/network/dhcp/default.nix index e14b15ac..dfaa4c9f 100644 --- a/hosts/vidhar/network/dhcp/default.nix +++ b/hosts/vidhar/network/dhcp/default.nix | |||
@@ -26,7 +26,7 @@ with lib; | |||
26 | { name = "ipxe"; | 26 | { name = "ipxe"; |
27 | test = "option[77].hex == 'iPXE'"; | 27 | test = "option[77].hex == 'iPXE'"; |
28 | next-server = "10.141.0.1"; | 28 | next-server = "10.141.0.1"; |
29 | boot-file-name = "installer-x86_64-linux/netboot.ipxe"; | 29 | boot-file-name = "http://nfsroot.vidhar.yggdrasil/installer-x86_64-linux/netboot.ipxe"; |
30 | only-if-required = true; | 30 | only-if-required = true; |
31 | } | 31 | } |
32 | { name = "uefi-64"; | 32 | { name = "uefi-64"; |
@@ -229,6 +229,40 @@ with lib; | |||
229 | sopsFile = ./knot-tsig.json.frag; | 229 | sopsFile = ./knot-tsig.json.frag; |
230 | }; | 230 | }; |
231 | 231 | ||
232 | services.nginx.virtualHosts."nfsroot.vidhar.yggdrasil" = { | ||
233 | addSSL = false; | ||
234 | forceSSL = false; | ||
235 | locations."/" = { | ||
236 | extraConfig = '' | ||
237 | autoindex on; | ||
238 | ''; | ||
239 | root = pkgs.symlinkJoin { | ||
240 | name = "nfsroot.vidhar.yggdrasil"; | ||
241 | paths = | ||
242 | (map (system: | ||
243 | let | ||
244 | installerBuild = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { | ||
245 | modules = [ | ||
246 | ({ ... }: { | ||
247 | config.nfsroot.storeDevice = "10.141.0.1:nix-store"; | ||
248 | config.nfsroot.registrationUrl = "http://nfsroot.vidhar.yggdrasil/installer-${system}/registration"; | ||
249 | }) | ||
250 | ]; | ||
251 | }).config.system.build; | ||
252 | in builtins.toPath (pkgs.runCommandLocal "install-${system}" {} '' | ||
253 | mkdir -p $out/installer-${system} | ||
254 | install -m 0444 -t $out/installer-${system} \ | ||
255 | ${installerBuild.initialRamdisk}/initrd \ | ||
256 | ${installerBuild.kernel}/bzImage \ | ||
257 | ${installerBuild.netbootIpxeScript}/netboot.ipxe \ | ||
258 | ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration | ||
259 | '') | ||
260 | ) ["x86_64-linux"] | ||
261 | ); | ||
262 | }; | ||
263 | }; | ||
264 | }; | ||
265 | |||
232 | systemd.services."pxe-atftpd" = { | 266 | systemd.services."pxe-atftpd" = { |
233 | description = "TFTP Server for PXE Booting"; | 267 | description = "TFTP Server for PXE Booting"; |
234 | after = [ "network.target" ]; | 268 | after = [ "network.target" ]; |
@@ -238,44 +272,16 @@ with lib; | |||
238 | additionalTargets = { | 272 | additionalTargets = { |
239 | "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; | 273 | "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; |
240 | }; | 274 | }; |
275 | additionalOptions = [ | ||
276 | "NSLOOKUP_CMD" | ||
277 | ]; | ||
241 | }; | 278 | }; |
242 | tftpRoot = pkgs.runCommandLocal "netboot" {} '' | 279 | tftpRoot = pkgs.runCommandLocal "netboot" {} '' |
243 | mkdir -p $out | 280 | mkdir -p $out |
244 | install -m 0444 -t $out \ | 281 | install -m 0444 -t $out \ |
245 | ${ipxe}/ipxe.efi ${ipxe}/i386-ipxe.efi ${ipxe}/undionly.kpxe | 282 | ${ipxe}/ipxe.efi ${ipxe}/i386-ipxe.efi ${ipxe}/undionly.kpxe |
246 | |||
247 | ${concatMapStringsSep "\n" (system: | ||
248 | let | ||
249 | installerBuild = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { | ||
250 | modules = [ | ||
251 | ({ ... }: { config.nfsroot.storeDevice = "vidhar:nix-store"; }) | ||
252 | ]; | ||
253 | }).config.system.build; | ||
254 | in '' | ||
255 | mkdir -p $out/installer-${system} | ||
256 | install -m 0444 -t $out/installer-${system} \ | ||
257 | ${installerBuild.initialRamdisk}/initrd \ | ||
258 | ${installerBuild.kernel}/bzImage \ | ||
259 | ${installerBuild.netbootIpxeScript}/netboot.ipxe | ||
260 | '' | ||
261 | ) ["x86_64-linux"]} | ||
262 | ''; | 283 | ''; |
263 | in "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address=10.141.0.1 ${tftpRoot}"; | 284 | in "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address=10.141.0.1 ${tftpRoot}"; |
264 | }; | 285 | }; |
265 | |||
266 | services.nfs.server = { | ||
267 | enable = true; | ||
268 | createMountPoints = true; | ||
269 | exports = '' | ||
270 | /export/nix-root 10.141.0.0/24(ro) | ||
271 | ''; | ||
272 | }; | ||
273 | |||
274 | fileSystems = { | ||
275 | "/export/nix-root" = { | ||
276 | device = "/nix/store"; | ||
277 | options = [ "bind" ]; | ||
278 | }; | ||
279 | }; | ||
280 | }; | 286 | }; |
281 | } | 287 | } |