diff options
author | Dan Peebles <pumpkin@me.com> | 2017-02-20 19:57:16 +0000 |
---|---|---|
committer | Dan Peebles <pumpkin@me.com> | 2017-04-16 16:09:41 +0000 |
commit | d990aa716327abb018e8352dcf7ba2fcfb4fc34c (patch) | |
tree | f7f2d0628ee05b9c77e3f15ce5b1e03b405584e2 /nixos/tests | |
parent | 91d2dc00bb12dc5b3aa51ea5391b7ba12b38269d (diff) | |
download | nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.tar nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.tar.gz nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.tar.bz2 nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.tar.lz nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.tar.xz nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.tar.zst nixlib-d990aa716327abb018e8352dcf7ba2fcfb4fc34c.zip |
Refactor nixos-install to separate out filesystem build logic
The key distinction I'm drawing is that there's a component that deals with the store of the machine being built, and another component for the store building it. The inner part of it assumes nothing from the builder (doesn't need chroot or root powers) so it can run comfortably inside a Nix build, as well as nixos-rebuild. I have some upcoming work that will use that to significantly speed up and streamline image builds for NixOS, especially on virtualized hosts like EC2, but it's also a reasonable speedup on native hosts.
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/installer.nix | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 35dd00fe630f..3ab3c1bac48a 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -34,6 +34,12 @@ let boot.loader.systemd-boot.enable = true; ''} + users.extraUsers.alice = { + isNormalUser = true; + home = "/home/alice"; + description = "Alice Foobar"; + }; + hardware.enableAllFirmware = lib.mkForce false; ${replaceChars ["\n"] ["\n "] extraConfig} @@ -96,7 +102,7 @@ let $machine->shutdown; # Now see if we can boot the installation. - $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "boot-after-install" }); # For example to enter LUKS passphrase. ${preBootCommands} @@ -118,11 +124,17 @@ let $machine->waitForUnit("swap.target"); $machine->succeed("cat /proc/swaps | grep -q /dev"); + # Check that the store is in good shape + $machine->succeed("nix-store --verify --check-contents >&2"); + # Check whether the channel works. $machine->succeed("nix-env -iA nixos.procps >&2"); $machine->succeed("type -tP ps | tee /dev/stderr") =~ /.nix-profile/ or die "nix-env failed"; + # Check that the daemon works, and that non-root users can run builds (this will build a new profile generation through the daemon) + $machine->succeed("su alice -l -c 'nix-env -iA nixos.procps' >&2"); + # We need to a writable nix-store on next boot. $machine->copyFileFromHost( "${ makeConfig { inherit bootLoader grubVersion grubDevice grubIdentifier extraConfig; forceGrubReinstallCount = 1; } }", @@ -139,7 +151,7 @@ let $machine->shutdown; # Check whether a writable store build works - $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "rebuild-switch" }); ${preBootCommands} $machine->waitForUnit("multi-user.target"); $machine->copyFileFromHost( @@ -150,7 +162,7 @@ let # And just to be sure, check that the machine still boots after # "nixos-rebuild switch". - $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", "boot-after-rebuild-switch" }); ${preBootCommands} $machine->waitForUnit("network.target"); $machine->shutdown; |