Loading nixos/modules/profiles/nix-builder-vm.nix +51 −31 Original line number Diff line number Diff line Loading @@ -6,7 +6,12 @@ It contains both the relevant guest settings as well as an installer script that manages it as a QEMU virtual machine on the host. */ { config, lib, options, ... }: { config, lib, options, ... }: let keysDirectory = "/var/keys"; Loading @@ -31,7 +36,10 @@ in ]; # swraid's default depends on stateVersion config.boot.swraid.enable = false; options.boot.isContainer = lib.mkOption { default = false; internal = true; }; options.boot.isContainer = lib.mkOption { default = false; internal = true; }; } ]; Loading Loading @@ -160,13 +168,20 @@ in script = hostPkgs.writeShellScriptBin "create-builder" ( '' set -euo pipefail '' + '' + # When running as non-interactively as part of a DarwinConfiguration the working directory # must be set to a writeable directory. (if cfg.workingDirectory != "." then '' ( if cfg.workingDirectory != "." then '' ${hostPkgs.coreutils}/bin/mkdir --parent "${cfg.workingDirectory}" cd "${cfg.workingDirectory}" '' else "") + '' '' else "" ) + '' KEYS="''${KEYS:-./keys}" ${hostPkgs.coreutils}/bin/mkdir --parent "''${KEYS}" PRIVATE_KEY="''${KEYS}/${user}_${keyType}" Loading @@ -179,7 +194,8 @@ in (set -x; sudo --reset-timestamp ${installCredentials} "''${KEYS}") fi KEYS="$(${hostPkgs.nix}/bin/nix-store --add "$KEYS")" ${lib.getExe config.system.build.vm} ''); '' ); in script.overrideAttrs (old: { Loading Loading @@ -224,7 +240,11 @@ in memorySize = cfg.memorySize; forwardPorts = [ { from = "host"; guest.port = 22; host.port = cfg.hostPort; } { from = "host"; guest.port = 22; host.port = cfg.hostPort; } ]; # Disable graphics for the builder since users will likely want to run it Loading Loading
nixos/modules/profiles/nix-builder-vm.nix +51 −31 Original line number Diff line number Diff line Loading @@ -6,7 +6,12 @@ It contains both the relevant guest settings as well as an installer script that manages it as a QEMU virtual machine on the host. */ { config, lib, options, ... }: { config, lib, options, ... }: let keysDirectory = "/var/keys"; Loading @@ -31,7 +36,10 @@ in ]; # swraid's default depends on stateVersion config.boot.swraid.enable = false; options.boot.isContainer = lib.mkOption { default = false; internal = true; }; options.boot.isContainer = lib.mkOption { default = false; internal = true; }; } ]; Loading Loading @@ -160,13 +168,20 @@ in script = hostPkgs.writeShellScriptBin "create-builder" ( '' set -euo pipefail '' + '' + # When running as non-interactively as part of a DarwinConfiguration the working directory # must be set to a writeable directory. (if cfg.workingDirectory != "." then '' ( if cfg.workingDirectory != "." then '' ${hostPkgs.coreutils}/bin/mkdir --parent "${cfg.workingDirectory}" cd "${cfg.workingDirectory}" '' else "") + '' '' else "" ) + '' KEYS="''${KEYS:-./keys}" ${hostPkgs.coreutils}/bin/mkdir --parent "''${KEYS}" PRIVATE_KEY="''${KEYS}/${user}_${keyType}" Loading @@ -179,7 +194,8 @@ in (set -x; sudo --reset-timestamp ${installCredentials} "''${KEYS}") fi KEYS="$(${hostPkgs.nix}/bin/nix-store --add "$KEYS")" ${lib.getExe config.system.build.vm} ''); '' ); in script.overrideAttrs (old: { Loading Loading @@ -224,7 +240,11 @@ in memorySize = cfg.memorySize; forwardPorts = [ { from = "host"; guest.port = 22; host.port = cfg.hostPort; } { from = "host"; guest.port = 22; host.port = cfg.hostPort; } ]; # Disable graphics for the builder since users will likely want to run it Loading