From ddcc8c65e30a9ca3b56e25466e749cb100b28510 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 22 Oct 2022 19:33:45 +0200 Subject: ... --- installer-profiles/nfsroot.nix | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'installer-profiles') diff --git a/installer-profiles/nfsroot.nix b/installer-profiles/nfsroot.nix index 9db415a8..2688a8d0 100644 --- a/installer-profiles/nfsroot.nix +++ b/installer-profiles/nfsroot.nix @@ -16,7 +16,17 @@ in { nfsroot = { storeDevice = mkOption { type = types.str; + default = "nfsroot:nix-store"; }; + + registrationUrl = mkOption { + type = types.str; + default = "http://nfsroot/nix-registration"; + }; + }; + + system.build = { + storeContents = mkOption {}; }; }; @@ -67,14 +77,26 @@ in { ]; }; + nix.extraOptions = '' + use-sqlite-wal = false + ''; + boot.initrd.availableKernelModules = [ "nfs" "nfsv4" "overlay" ]; boot.initrd.supportedFilesystems = [ "nfs" "nfsv4" "overlay" ]; + services.rpcbind.enable = mkImageMediaOverride false; boot.initrd.network.enable = true; - boot.initrd.network.flushBeforeStage2 = false; # otherwise nfs dosen't work + boot.initrd.network.flushBeforeStage2 = false; # otherwise nfs doesn't work + boot.initrd.postMountCommands = '' + mkdir -p /mnt-root/etc/ + cp /etc/resolv.conf /mnt-root/etc/resolv.conf + ''; networking.useDHCP = true; + networking.resolvconf.enable = false; + system.build.storeContents = [config.system.build.toplevel]; + system.build.netbootIpxeScript = pkgs.writeTextDir "netboot.ipxe" '' #!ipxe # Use the cmdline variable to allow the user to specify custom kernel params @@ -86,6 +108,10 @@ in { boot.postBootCommands = '' + # After booting, register the contents of the Nix store on NFS + # in the Nix database in the tmpfs. + ${pkgs.curl}/bin/curl ${escapeShellArg cfg.registrationUrl} | ${config.nix.package.out}/bin/nix-store --load-db + # nixos-rebuild also requires a "system" profile and an # /etc/NIXOS tag. touch /etc/NIXOS -- cgit v1.2.3