From ddcc8c65e30a9ca3b56e25466e749cb100b28510 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 22 Oct 2022 19:33:45 +0200 Subject: ... --- hosts/vidhar/network/dhcp/default.nix | 70 +++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'hosts/vidhar/network/dhcp') 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; { name = "ipxe"; test = "option[77].hex == 'iPXE'"; next-server = "10.141.0.1"; - boot-file-name = "installer-x86_64-linux/netboot.ipxe"; + boot-file-name = "http://nfsroot.vidhar.yggdrasil/installer-x86_64-linux/netboot.ipxe"; only-if-required = true; } { name = "uefi-64"; @@ -229,6 +229,40 @@ with lib; sopsFile = ./knot-tsig.json.frag; }; + services.nginx.virtualHosts."nfsroot.vidhar.yggdrasil" = { + addSSL = false; + forceSSL = false; + locations."/" = { + extraConfig = '' + autoindex on; + ''; + root = pkgs.symlinkJoin { + name = "nfsroot.vidhar.yggdrasil"; + paths = + (map (system: + let + installerBuild = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { + modules = [ + ({ ... }: { + config.nfsroot.storeDevice = "10.141.0.1:nix-store"; + config.nfsroot.registrationUrl = "http://nfsroot.vidhar.yggdrasil/installer-${system}/registration"; + }) + ]; + }).config.system.build; + in builtins.toPath (pkgs.runCommandLocal "install-${system}" {} '' + mkdir -p $out/installer-${system} + install -m 0444 -t $out/installer-${system} \ + ${installerBuild.initialRamdisk}/initrd \ + ${installerBuild.kernel}/bzImage \ + ${installerBuild.netbootIpxeScript}/netboot.ipxe \ + ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration + '') + ) ["x86_64-linux"] + ); + }; + }; + }; + systemd.services."pxe-atftpd" = { description = "TFTP Server for PXE Booting"; after = [ "network.target" ]; @@ -238,44 +272,16 @@ with lib; additionalTargets = { "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; }; + additionalOptions = [ + "NSLOOKUP_CMD" + ]; }; tftpRoot = pkgs.runCommandLocal "netboot" {} '' mkdir -p $out install -m 0444 -t $out \ ${ipxe}/ipxe.efi ${ipxe}/i386-ipxe.efi ${ipxe}/undionly.kpxe - - ${concatMapStringsSep "\n" (system: - let - installerBuild = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { - modules = [ - ({ ... }: { config.nfsroot.storeDevice = "vidhar:nix-store"; }) - ]; - }).config.system.build; - in '' - mkdir -p $out/installer-${system} - install -m 0444 -t $out/installer-${system} \ - ${installerBuild.initialRamdisk}/initrd \ - ${installerBuild.kernel}/bzImage \ - ${installerBuild.netbootIpxeScript}/netboot.ipxe - '' - ) ["x86_64-linux"]} ''; in "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address=10.141.0.1 ${tftpRoot}"; }; - - services.nfs.server = { - enable = true; - createMountPoints = true; - exports = '' - /export/nix-root 10.141.0.0/24(ro) - ''; - }; - - fileSystems = { - "/export/nix-root" = { - device = "/nix/store"; - options = [ "bind" ]; - }; - }; }; } -- cgit v1.2.3