@@ -3,7 +3,7 @@
33 pkgs ? import ../.. { inherit system config; }
44}:
55
6−with import ../lib/testing.nix { inherit system pkgs; };
6+with import ../lib/testing-python.nix { inherit system pkgs; };
77with pkgs.lib;
88
99let
@@ -67,161 +67,193 @@ let
6767 , grubIdentifier, preBootCommands, extraConfig
6868 , testCloneConfig
6969 }:
70− let
71− iface = if grubVersion == 1 then "ide" else "virtio";
72− isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi);
73−
74− # FIXME don't duplicate the -enable-kvm etc. flags here yet again!
75− qemuFlags =
76− (if system == "x86_64-linux" then "-m 768 " else "-m 512 ") +
77− (optionalString (system == "x86_64-linux") "-cpu host ") +
78− (optionalString (system == "aarch64-linux") "-enable-kvm -machine virt,gic-version=host -cpu host ");
79−
80− hdFlags = ''hda => "vm-state-machine/machine.qcow2", hdaInterface => "${iface}", ''
81− + optionalString isEfi (if pkgs.stdenv.isAarch64
82− then ''bios => "${pkgs.OVMF.fd}/FV/QEMU_EFI.fd", ''
83− else ''bios => "${pkgs.OVMF.fd}/FV/OVMF.fd", '');
70+ let iface = if grubVersion == 1 then "ide" else "virtio";
71+ isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi);
72+ bios = if pkgs.stdenv.isAarch64 then "QEMU_EFI.fd" else "OVMF.fd";
8473 in if !isEfi && !(pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) then
8574 throw "Non-EFI boot methods are only supported on i686 / x86_64"
8675 else ''
76+ def assemble_qemu_flags():
77+ flags = "-cpu host"
78+ ${if system == "x86_64-linux"
79+ then ''flags += " -m 768"''
80+ else ''flags += " -m 512 -enable-kvm -machine virt,gic-version=host"''
81+ }
82+ return flags
8783
88− $machine->start;
8984
90− # Make sure that we get a login prompt etc.
91− $machine->succeed("echo hello");
92− #$machine->waitForUnit('getty@tty2');
93− #$machine->waitForUnit("rogue");
94− $machine->waitForUnit("nixos-manual");
85+ qemu_flags = {"qemuFlags": assemble_qemu_flags()}
9586
96− # Wait for hard disks to appear in /dev
97− $machine->succeed("udevadm settle");
87+ hd_flags = {
88+ "hdaInterface": "${iface}",
89+ "hda": "vm-state-machine/machine.qcow2",
90+ }
91+ ${optionalString isEfi ''
92+ hd_flags.update(
93+ bios="${pkgs.OVMF.fd}/FV/${bios}"
94+ )''
95+ }
96+ default_flags = {**hd_flags, **qemu_flags}
9897
99− # Partition the disk.
100− ${createPartitions}
10198
102− # Create the NixOS configuration.
103− $machine->succeed("nixos-generate-config --root /mnt");
99+ def create_machine_named(name):
100+ return create_machine({**default_flags, "name": "boot-after-install"})
104101
105− $machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
106102
107− $machine->copyFileFromHost(
108− "${ makeConfig { inherit bootLoader grubVersion grubDevice grubIdentifier grubUseEfi extraConfig; } }",
109− "/mnt/etc/nixos/configuration.nix");
103+ machine.start()
110104
111− # Perform the installation.
112− $machine->succeed("nixos-install < /dev/null >&2");
105+ with subtest("Assert readiness of login prompt"):
106+ machine.succeed("echo hello")
107+ machine.wait_for_unit("nixos-manual")
113108
114− # Do it again to make sure it's idempotent.
115− $machine->succeed("nixos-install < /dev/null >&2");
109+ with subtest("Wait for hard disks to appear in /dev"):
110+ machine.succeed("udevadm settle")
116111
117− $machine->succeed("umount /mnt/boot || true");
118− $machine->succeed("umount /mnt");
119− $machine->succeed("sync");
112+ ${createPartitions}
120113
121− $machine->shutdown;
114+ with subtest("Create the NixOS configuration"):
115+ machine.succeed("nixos-generate-config --root /mnt")
116+ machine.succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2")
117+ machine.copy_from_host(
118+ "${ makeConfig {
119+ inherit bootLoader grubVersion grubDevice grubIdentifier
120+ grubUseEfi extraConfig;
121+ }
122+ }",
123+ "/mnt/etc/nixos/configuration.nix",
124+ )
125+
126+ with subtest("Perform the installation"):
127+ machine.succeed("nixos-install < /dev/null >&2")
128+
129+ with subtest("Do it again to make sure it's idempotent"):
130+ machine.succeed("nixos-install < /dev/null >&2")
131+
132+ with subtest("Shutdown system after installation"):
133+ machine.succeed("umount /mnt/boot || true")
134+ machine.succeed("umount /mnt")
135+ machine.succeed("sync")
136+ machine.shutdown()
122137
123138 # Now see if we can boot the installation.
124− $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "boot-after-install" });
139+ machine = create_machine_named("boot-after-install")
125140
126141 # For example to enter LUKS passphrase.
127142 ${preBootCommands}
128143
129− # Did /boot get mounted?
130− $machine->waitForUnit("local-fs.target");
131−
132− ${if bootLoader == "grub" then
133− ''$machine->succeed("test -e /boot/grub");''
134− else
135− ''$machine->succeed("test -e /boot/loader/loader.conf");''
136− }
137−
138− # Check whether /root has correct permissions.
139− $machine->succeed("stat -c '%a' /root") =~ /700/ or die;
140−
141− # Did the swap device get activated?
142− # uncomment once https://bugs.freedesktop.org/show_bug.cgi?id=86930 is resolved
143− $machine->waitForUnit("swap.target");
144− $machine->succeed("cat /proc/swaps | grep -q /dev");
145−
146− # Check that the store is in good shape
147− $machine->succeed("nix-store --verify --check-contents >&2");
148−
149− # Check whether the channel works.
150− $machine->succeed("nix-env -iA nixos.procps >&2");
151− $machine->succeed("type -tP ps | tee /dev/stderr") =~ /.nix-profile/
152− or die "nix-env failed";
153−
154− # Check that the daemon works, and that non-root users can run builds (this will build a new profile generation through the daemon)
155− $machine->succeed("su alice -l -c 'nix-env -iA nixos.procps' >&2");
156−
157− # We need a writable Nix store on next boot.
158− $machine->copyFileFromHost(
159− "${ makeConfig { inherit bootLoader grubVersion grubDevice grubIdentifier grubUseEfi extraConfig; forceGrubReinstallCount = 1; } }",
160− "/etc/nixos/configuration.nix");
161−
162− # Check whether nixos-rebuild works.
163− $machine->succeed("nixos-rebuild switch >&2");
164−
165− # Test nixos-option.
166− $machine->succeed("nixos-option boot.initrd.kernelModules | grep virtio_console");
167− $machine->succeed("nixos-option boot.initrd.kernelModules | grep 'List of modules'");
168− $machine->succeed("nixos-option boot.initrd.kernelModules | grep qemu-guest.nix");
169−
170− $machine->shutdown;
144+ with subtest("Assert that /boot get mounted"):
145+ machine.wait_for_unit("local-fs.target")
146+ ${if bootLoader == "grub"
147+ then ''machine.succeed("test -e /boot/grub")''
148+ else ''machine.succeed("test -e /boot/loader/loader.conf")''
149+ }
150+
151+ with subtest("Check whether /root has correct permissions"):
152+ assert "700" in machine.succeed("stat -c '%a' /root")
153+
154+ with subtest("Assert swap device got activated"):
155+ # uncomment once https://bugs.freedesktop.org/show_bug.cgi?id=86930 is resolved
156+ machine.wait_for_unit("swap.target")
157+ machine.succeed("cat /proc/swaps | grep -q /dev")
158+
159+ with subtest("Check that the store is in good shape"):
160+ machine.succeed("nix-store --verify --check-contents >&2")
161+
162+ with subtest("Check whether the channel works"):
163+ machine.succeed("nix-env -iA nixos.procps >&2")
164+ assert ".nix-profile" in machine.succeed("type -tP ps | tee /dev/stderr")
165+
166+ with subtest(
167+ "Check that the daemon works, and that non-root users can run builds "
168+ "(this will build a new profile generation through the daemon)"
169+ ):
170+ machine.succeed("su alice -l -c 'nix-env -iA nixos.procps' >&2")
171+
172+ with subtest("Configure system with writable Nix store on next boot"):
173+ # we're not using copy_from_host here because the installer image
174+ # doesn't know about the host-guest sharing mechanism.
175+ machine.copy_from_host_via_shell(
176+ "${ makeConfig {
177+ inherit bootLoader grubVersion grubDevice grubIdentifier
178+ grubUseEfi extraConfig;
179+ forceGrubReinstallCount = 1;
180+ }
181+ }",
182+ "/etc/nixos/configuration.nix",
183+ )
184+
185+ with subtest("Check whether nixos-rebuild works"):
186+ machine.succeed("nixos-rebuild switch >&2")
187+
188+ with subtest("Test nixos-option"):
189+ kernel_modules = machine.succeed("nixos-option boot.initrd.kernelModules")
190+ assert "virtio_console" in kernel_modules
191+ assert "List of modules" in kernel_modules
192+ assert "qemu-guest.nix" in kernel_modules
193+
194+ machine.shutdown()
171195
172196 # Check whether a writable store build works
173− $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "rebuild-switch" });
197+ machine = create_machine_named("rebuild-switch")
174198 ${preBootCommands}
175− $machine->waitForUnit("multi-user.target");
176− $machine->copyFileFromHost(
177− "${ makeConfig { inherit bootLoader grubVersion grubDevice grubIdentifier grubUseEfi extraConfig; forceGrubReinstallCount = 2; } }",
178− "/etc/nixos/configuration.nix");
179− $machine->succeed("nixos-rebuild boot >&2");
180− $machine->shutdown;
199+ machine.wait_for_unit("multi-user.target")
200+
201+ # we're not using copy_from_host here because the installer image
202+ # doesn't know about the host-guest sharing mechanism.
203+ machine.copy_from_host_via_shell(
204+ "${ makeConfig {
205+ inherit bootLoader grubVersion grubDevice grubIdentifier
206+ grubUseEfi extraConfig;
207+ forceGrubReinstallCount = 2;
208+ }
209+ }",
210+ "/etc/nixos/configuration.nix",
211+ )
212+ machine.succeed("nixos-rebuild boot >&2")
213+ machine.shutdown()
181214
182215 # And just to be sure, check that the machine still boots after
183216 # "nixos-rebuild switch".
184− $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", "boot-after-rebuild-switch" });
217+ machine = create_machine_named("boot-after-rebuild-switch")
185218 ${preBootCommands}
186− $machine->waitForUnit("network.target");
187− $machine->shutdown;
219+ machine.wait_for_unit("network.target")
220+ machine.shutdown()
188221
189222 # Tests for validating clone configuration entries in grub menu
190− ${optionalString testCloneConfig ''
191− # Reboot Machine
192− $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "clone-default-config" });
193− ${preBootCommands}
194− $machine->waitForUnit("multi-user.target");
195−
196− # Booted configuration name should be Home
197− # This is not the name that shows in the grub menu.
198− # The default configuration is always shown as "Default"
199− $machine->succeed("cat /run/booted-system/configuration-name >&2");
200− $machine->succeed("cat /run/booted-system/configuration-name | grep Home");
223+ ''
224+ + optionalString testCloneConfig ''
225+ # Reboot Machine
226+ machine = create_machine_named("clone-default-config")
227+ ${preBootCommands}
228+ machine.wait_for_unit("multi-user.target")
201229
202− # We should find **not** a file named /etc/gitconfig
203− $machine->fail("test -e /etc/gitconfig");
230+ with subtest("Booted configuration name should be 'Home'"):
231+ # This is not the name that shows in the grub menu.
232+ # The default configuration is always shown as "Default"
233+ machine.succeed("cat /run/booted-system/configuration-name >&2")
234+ assert "Home" in machine.succeed("cat /run/booted-system/configuration-name")
204235
205− # Set grub to boot the second configuration
206− $machine->succeed("grub-reboot 1");
236+ with subtest("We should **not** find a file named /etc/gitconfig"):
237+ machine.fail("test -e /etc/gitconfig")
207238
208− $machine->shutdown;
239+ with subtest("Set grub to boot the second configuration"):
240+ machine.succeed("grub-reboot 1")
209241
210− # Reboot Machine
211− $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "clone-alternate-config" });
212− ${preBootCommands}
242+ machine.shutdown()
213243
214− $machine->waitForUnit("multi-user.target");
215− # Booted configuration name should be Work
216− $machine->succeed("cat /run/booted-system/configuration-name >&2");
217− $machine->succeed("cat /run/booted-system/configuration-name | grep Work");
244+ # Reboot Machine
245+ machine = create_machine_named("clone-alternate-config")
246+ ${preBootCommands}
218247
219− # We should find a file named /etc/gitconfig
220− $machine->succeed("test -e /etc/gitconfig");
248+ machine.wait_for_unit("multi-user.target")
249+ with subtest("Booted configuration name should be Work"):
250+ machine.succeed("cat /run/booted-system/configuration-name >&2")
251+ assert "Work" in machine.succeed("cat /run/booted-system/configuration-name")
221252
222− $machine->shutdown;
223− ''}
253+ with subtest("We should find a file named /etc/gitconfig"):
254+ machine.succeed("test -e /etc/gitconfig")
224255
256+ machine.shutdown()
225257 '';
226258
227259
@@ -243,63 +275,63 @@ let
243275 nodes = {
244276
245277 # The configuration of the machine used to run "nixos-install".
246− machine =
247− { pkgs, ... }:
248−
249− { imports =
250− [ ../modules/profiles/installation-device.nix
251− ../modules/profiles/base.nix
252− extraInstallerConfig
253− ];
254−
255− virtualisation.diskSize = 8 * 1024;
256− virtualisation.memorySize = 1024;
257−
258− # Use a small /dev/vdb as the root disk for the
259− # installer. This ensures the target disk (/dev/vda) is
260− # the same during and after installation.
261− virtualisation.emptyDiskImages = [ 512 ];
262− virtualisation.bootDevice =
263− if grubVersion == 1 then "/dev/sdb" else "/dev/vdb";
264− virtualisation.qemu.diskInterface =
265− if grubVersion == 1 then "scsi" else "virtio";
266−
267− boot.loader.systemd-boot.enable = mkIf (bootLoader == "systemd-boot") true;
268−
269− hardware.enableAllFirmware = mkForce false;
270−
271− # The test cannot access the network, so any packages we
272− # need must be included in the VM.
273− system.extraDependencies = with pkgs;
274− [ sudo
275− libxml2.bin
276− libxslt.bin
277− desktop-file-utils
278− docbook5
279− docbook_xsl_ns
280− unionfs-fuse
281− ntp
282− nixos-artwork.wallpapers.simple-dark-gray-bottom
283− perlPackages.XMLLibXML
284− perlPackages.ListCompare
285− shared-mime-info
286− texinfo
287− xorg.lndir
288−
289− # add curl so that rather than seeing the test attempt to download
290− # curl's tarball, we see what it's trying to download
291− curl
292− ]
293− ++ optional (bootLoader == "grub" && grubVersion == 1) pkgs.grub
294− ++ optionals (bootLoader == "grub" && grubVersion == 2) [ pkgs.grub2 pkgs.grub2_efi ];
295−
296− nix.binaryCaches = mkForce [ ];
297− nix.extraOptions =
298− ''
299− hashed-mirrors =
300− connect-timeout = 1
301− '';
302− };
278+ machine = { pkgs, ... }: {
279+ imports = [
280+ ../modules/profiles/installation-device.nix
281+ ../modules/profiles/base.nix
282+ extraInstallerConfig
283+ ];
284+
285+ virtualisation.diskSize = 8 * 1024;
286+ virtualisation.memorySize = 1024;
287+
288+ # Use a small /dev/vdb as the root disk for the
289+ # installer. This ensures the target disk (/dev/vda) is
290+ # the same during and after installation.
291+ virtualisation.emptyDiskImages = [ 512 ];
292+ virtualisation.bootDevice =
293+ if grubVersion == 1 then "/dev/sdb" else "/dev/vdb";
294+ virtualisation.qemu.diskInterface =
295+ if grubVersion == 1 then "scsi" else "virtio";
296+
297+ boot.loader.systemd-boot.enable = mkIf (bootLoader == "systemd-boot") true;
298+
299+ hardware.enableAllFirmware = mkForce false;
300+
301+ # The test cannot access the network, so any packages we
302+ # need must be included in the VM.
303+ system.extraDependencies = with pkgs; [
304+ desktop-file-utils
305+ docbook5
306+ docbook_xsl_ns
307+ libxml2.bin
308+ libxslt.bin
309+ nixos-artwork.wallpapers.simple-dark-gray-bottom
310+ ntp
311+ perlPackages.ListCompare
312+ perlPackages.XMLLibXML
313+ shared-mime-info
314+ sudo
315+ texinfo
316+ unionfs-fuse
317+ xorg.lndir
318+
319+ # add curl so that rather than seeing the test attempt to download
320+ # curl's tarball, we see what it's trying to download
321+ curl
322+ ]
323+ ++ optional (bootLoader == "grub" && grubVersion == 1) pkgs.grub
324+ ++ optionals (bootLoader == "grub" && grubVersion == 2) [
325+ pkgs.grub2
326+ pkgs.grub2_efi
327+ ];
328+
329+ nix.binaryCaches = mkForce [ ];
330+ nix.extraOptions = ''
331+ hashed-mirrors =
332+ connect-timeout = 1
333+ '';
334+ };
303335
304336 };
305337
@@ -310,13 +342,13 @@ let
310342 };
311343 };
312344
313− makeLuksRootTest = name: luksFormatOpts: makeInstallerTest name
314− { createPartitions = ''
315− $machine->succeed(
345+ makeLuksRootTest = name: luksFormatOpts: makeInstallerTest name {
346+ createPartitions = ''
347+ machine.succeed(
316348 "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
317− . " mkpart primary ext2 1M 50MB" # /boot
318− . " mkpart primary linux-swap 50M 1024M"
319− . " mkpart primary 1024M -1s", # LUKS
349+ + " mkpart primary ext2 1M 50MB" # /boot
350+ + " mkpart primary linux-swap 50M 1024M"
351+ + " mkpart primary 1024M -1s", # LUKS
320352 "udevadm settle",
321353 "mkswap /dev/vda2 -L swap",
322354 "swapon -L swap",
@@ -328,77 +360,74 @@ let
328360 "mkfs.ext3 -L boot /dev/vda1",
329361 "mkdir -p /mnt/boot",
330362 "mount LABEL=boot /mnt/boot",
331− );
332− '';
333− extraConfig = ''
334− boot.kernelParams = lib.mkAfter [ "console=tty0" ];
335− '';
336− enableOCR = true;
337− preBootCommands = ''
338− $machine->start;
339− $machine->waitForText(qr/Passphrase for/);
340− $machine->sendChars("supersecret\n");
341− '';
342− };
363+ )
364+ '';
365+ extraConfig = ''
366+ boot.kernelParams = lib.mkAfter [ "console=tty0" ];
367+ '';
368+ enableOCR = true;
369+ preBootCommands = ''
370+ machine.start()
371+ machine.wait_for_text("Passphrase for")
372+ machine.send_chars("supersecret\n")
373+ '';
374+ };
343375
344376 # The (almost) simplest partitioning scheme: a swap partition and
345377 # one big filesystem partition.
346− simple-test-config = { createPartitions =
347− ''
348− $machine->succeed(
349− "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
350− . " mkpart primary linux-swap 1M 1024M"
351− . " mkpart primary ext2 1024M -1s",
352− "udevadm settle",
353− "mkswap /dev/vda1 -L swap",
354− "swapon -L swap",
355− "mkfs.ext3 -L nixos /dev/vda2",
356− "mount LABEL=nixos /mnt",
357− );
358− '';
359− };
360−
361− simple-uefi-grub-config =
362− { createPartitions =
363− ''
364− $machine->succeed(
365− "flock /dev/vda parted --script /dev/vda -- mklabel gpt"
366− . " mkpart ESP fat32 1M 50MiB" # /boot
367− . " set 1 boot on"
368− . " mkpart primary linux-swap 50MiB 1024MiB"
369− . " mkpart primary ext2 1024MiB -1MiB", # /
370− "udevadm settle",
371− "mkswap /dev/vda2 -L swap",
372− "swapon -L swap",
373− "mkfs.ext3 -L nixos /dev/vda3",
374− "mount LABEL=nixos /mnt",
375− "mkfs.vfat -n BOOT /dev/vda1",
376− "mkdir -p /mnt/boot",
377− "mount LABEL=BOOT /mnt/boot",
378− );
379− '';
380− bootLoader = "grub";
381− grubUseEfi = true;
382− };
378+ simple-test-config = {
379+ createPartitions = ''
380+ machine.succeed(
381+ "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
382+ + " mkpart primary linux-swap 1M 1024M"
383+ + " mkpart primary ext2 1024M -1s",
384+ "udevadm settle",
385+ "mkswap /dev/vda1 -L swap",
386+ "swapon -L swap",
387+ "mkfs.ext3 -L nixos /dev/vda2",
388+ "mount LABEL=nixos /mnt",
389+ )
390+ '';
391+ };
392+
393+ simple-uefi-grub-config = {
394+ createPartitions = ''
395+ machine.succeed(
396+ "flock /dev/vda parted --script /dev/vda -- mklabel gpt"
397+ + " mkpart ESP fat32 1M 50MiB" # /boot
398+ + " set 1 boot on"
399+ + " mkpart primary linux-swap 50MiB 1024MiB"
400+ + " mkpart primary ext2 1024MiB -1MiB", # /
401+ "udevadm settle",
402+ "mkswap /dev/vda2 -L swap",
403+ "swapon -L swap",
404+ "mkfs.ext3 -L nixos /dev/vda3",
405+ "mount LABEL=nixos /mnt",
406+ "mkfs.vfat -n BOOT /dev/vda1",
407+ "mkdir -p /mnt/boot",
408+ "mount LABEL=BOOT /mnt/boot",
409+ )
410+ '';
411+ bootLoader = "grub";
412+ grubUseEfi = true;
413+ };
383414
384− clone-test-extraconfig = { extraConfig =
385− ''
386− environment.systemPackages = [ pkgs.grub2 ];
387− boot.loader.grub.configurationName = "Home";
388− nesting.clone = [
389− {
390− boot.loader.grub.configurationName = lib.mkForce "Work";
391−
392− environment.etc = {
393− "gitconfig".text = "
394− [core]
395− gitproxy = none for work.com
396− ";
397− };
398− }
399− ];
400− '';
401− testCloneConfig = true;
415+ clone-test-extraconfig = {
416+ extraConfig = ''
417+ environment.systemPackages = [ pkgs.grub2 ];
418+ boot.loader.grub.configurationName = "Home";
419+ nesting.clone = [ {
420+ boot.loader.grub.configurationName = lib.mkForce "Work";
421+
422+ environment.etc = {
423+ "gitconfig".text = "
424+ [core]
425+ gitproxy = none for work.com
426+ ";
427+ };
428+ } ];
429+ '';
430+ testCloneConfig = true;
402431 };
403432
404433
@@ -415,27 +444,26 @@ in {
415444 simpleClone = makeInstallerTest "simpleClone" (simple-test-config // clone-test-extraconfig);
416445
417446 # Simple GPT/UEFI configuration using systemd-boot with 3 partitions: ESP, swap & root filesystem
418− simpleUefiSystemdBoot = makeInstallerTest "simpleUefiSystemdBoot"
419− { createPartitions =
420− ''
421− $machine->succeed(
422− "flock /dev/vda parted --script /dev/vda -- mklabel gpt"
423− . " mkpart ESP fat32 1M 50MiB" # /boot
424− . " set 1 boot on"
425− . " mkpart primary linux-swap 50MiB 1024MiB"
426− . " mkpart primary ext2 1024MiB -1MiB", # /
427− "udevadm settle",
428− "mkswap /dev/vda2 -L swap",
429− "swapon -L swap",
430− "mkfs.ext3 -L nixos /dev/vda3",
431− "mount LABEL=nixos /mnt",
432− "mkfs.vfat -n BOOT /dev/vda1",
433− "mkdir -p /mnt/boot",
434− "mount LABEL=BOOT /mnt/boot",
435− );
436− '';
437− bootLoader = "systemd-boot";
438− };
447+ simpleUefiSystemdBoot = makeInstallerTest "simpleUefiSystemdBoot" {
448+ createPartitions = ''
449+ machine.succeed(
450+ "flock /dev/vda parted --script /dev/vda -- mklabel gpt"
451+ + " mkpart ESP fat32 1M 50MiB" # /boot
452+ + " set 1 boot on"
453+ + " mkpart primary linux-swap 50MiB 1024MiB"
454+ + " mkpart primary ext2 1024MiB -1MiB", # /
455+ "udevadm settle",
456+ "mkswap /dev/vda2 -L swap",
457+ "swapon -L swap",
458+ "mkfs.ext3 -L nixos /dev/vda3",
459+ "mount LABEL=nixos /mnt",
460+ "mkfs.vfat -n BOOT /dev/vda1",
461+ "mkdir -p /mnt/boot",
462+ "mount LABEL=BOOT /mnt/boot",
463+ )
464+ '';
465+ bootLoader = "systemd-boot";
466+ };
439467
440468 simpleUefiGrub = makeInstallerTest "simpleUefiGrub" simple-uefi-grub-config;
441469
@@ -443,107 +471,99 @@ in {
443471 simpleUefiGrubClone = makeInstallerTest "simpleUefiGrubClone" (simple-uefi-grub-config // clone-test-extraconfig);
444472
445473 # Same as the previous, but now with a separate /boot partition.
446− separateBoot = makeInstallerTest "separateBoot"
447− { createPartitions =
448− ''
449− $machine->succeed(
450− "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
451− . " mkpart primary ext2 1M 50MB" # /boot
452− . " mkpart primary linux-swap 50MB 1024M"
453− . " mkpart primary ext2 1024M -1s", # /
454− "udevadm settle",
455− "mkswap /dev/vda2 -L swap",
456− "swapon -L swap",
457− "mkfs.ext3 -L nixos /dev/vda3",
458− "mount LABEL=nixos /mnt",
459− "mkfs.ext3 -L boot /dev/vda1",
460− "mkdir -p /mnt/boot",
461− "mount LABEL=boot /mnt/boot",
462− );
463− '';
464− };
474+ separateBoot = makeInstallerTest "separateBoot" {
475+ createPartitions = ''
476+ machine.succeed(
477+ "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
478+ + " mkpart primary ext2 1M 50MB" # /boot
479+ + " mkpart primary linux-swap 50MB 1024M"
480+ + " mkpart primary ext2 1024M -1s", # /
481+ "udevadm settle",
482+ "mkswap /dev/vda2 -L swap",
483+ "swapon -L swap",
484+ "mkfs.ext3 -L nixos /dev/vda3",
485+ "mount LABEL=nixos /mnt",
486+ "mkfs.ext3 -L boot /dev/vda1",
487+ "mkdir -p /mnt/boot",
488+ "mount LABEL=boot /mnt/boot",
489+ )
490+ '';
491+ };
465492
466493 # Same as the previous, but with fat32 /boot.
467− separateBootFat = makeInstallerTest "separateBootFat"
468− { createPartitions =
469− ''
470− $machine->succeed(
471− "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
472− . " mkpart primary ext2 1M 50MB" # /boot
473− . " mkpart primary linux-swap 50MB 1024M"
474− . " mkpart primary ext2 1024M -1s", # /
475− "udevadm settle",
476− "mkswap /dev/vda2 -L swap",
477− "swapon -L swap",
478− "mkfs.ext3 -L nixos /dev/vda3",
479− "mount LABEL=nixos /mnt",
480− "mkfs.vfat -n BOOT /dev/vda1",
481− "mkdir -p /mnt/boot",
482− "mount LABEL=BOOT /mnt/boot",
483− );
484− '';
485− };
494+ separateBootFat = makeInstallerTest "separateBootFat" {
495+ createPartitions = ''
496+ machine.succeed(
497+ "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
498+ + " mkpart primary ext2 1M 50MB" # /boot
499+ + " mkpart primary linux-swap 50MB 1024M"
500+ + " mkpart primary ext2 1024M -1s", # /
501+ "udevadm settle",
502+ "mkswap /dev/vda2 -L swap",
503+ "swapon -L swap",
504+ "mkfs.ext3 -L nixos /dev/vda3",
505+ "mount LABEL=nixos /mnt",
506+ "mkfs.vfat -n BOOT /dev/vda1",
507+ "mkdir -p /mnt/boot",
508+ "mount LABEL=BOOT /mnt/boot",
509+ )
510+ '';
511+ };
486512
487513 # zfs on / with swap
488− zfsroot = makeInstallerTest "zfs-root"
489− {
490− extraInstallerConfig = {
491− boot.supportedFilesystems = [ "zfs" ];
492− };
493−
494− extraConfig = ''
495− boot.supportedFilesystems = [ "zfs" ];
496−
497− # Using by-uuid overrides the default of by-id, and is unique
498− # to the qemu disks, as they don't produce by-id paths for
499− # some reason.
500− boot.zfs.devNodes = "/dev/disk/by-uuid/";
501− networking.hostId = "00000000";
502− '';
503−
504− createPartitions =
505− ''
506− $machine->succeed(
507− "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
508− . " mkpart primary linux-swap 1M 1024M"
509− . " mkpart primary 1024M -1s",
510− "udevadm settle",
514+ zfsroot = makeInstallerTest "zfs-root" {
515+ extraInstallerConfig = {
516+ boot.supportedFilesystems = [ "zfs" ];
517+ };
511518
512− "mkswap /dev/vda1 -L swap",
513− "swapon -L swap",
519+ extraConfig = ''
520+ boot.supportedFilesystems = [ "zfs" ];
514521
515− "zpool create rpool /dev/vda2",
516− "zfs create -o mountpoint=legacy rpool/root",
517− "mount -t zfs rpool/root /mnt",
522+ # Using by-uuid overrides the default of by-id, and is unique
523+ # to the qemu disks, as they don't produce by-id paths for
524+ # some reason.
525+ boot.zfs.devNodes = "/dev/disk/by-uuid/";
526+ networking.hostId = "00000000";
527+ '';
518528
519− "udevadm settle"
520− );
521− '';
522− };
529+ createPartitions = ''
530+ machine.succeed(
531+ "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
532+ + " mkpart primary linux-swap 1M 1024M"
533+ + " mkpart primary 1024M -1s",
534+ "udevadm settle",
535+ "mkswap /dev/vda1 -L swap",
536+ "swapon -L swap",
537+ "zpool create rpool /dev/vda2",
538+ "zfs create -o mountpoint=legacy rpool/root",
539+ "mount -t zfs rpool/root /mnt",
540+ "udevadm settle",
541+ )
542+ '';
543+ };
523544
524545 # Create two physical LVM partitions combined into one volume group
525546 # that contains the logical swap and root partitions.
526− lvm = makeInstallerTest "lvm"
527− { createPartitions =
528− ''
529− $machine->succeed(
530− "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
531− . " mkpart primary 1M 2048M" # PV1
532− . " set 1 lvm on"
533− . " mkpart primary 2048M -1s" # PV2
534− . " set 2 lvm on",
535− "udevadm settle",
536− "pvcreate /dev/vda1 /dev/vda2",
537− "vgcreate MyVolGroup /dev/vda1 /dev/vda2",
538− "lvcreate --size 1G --name swap MyVolGroup",
539− "lvcreate --size 2G --name nixos MyVolGroup",
540− "mkswap -f /dev/MyVolGroup/swap -L swap",
541− "swapon -L swap",
542− "mkfs.xfs -L nixos /dev/MyVolGroup/nixos",
543− "mount LABEL=nixos /mnt",
544− );
545− '';
546− };
547+ lvm = makeInstallerTest "lvm" {
548+ createPartitions = ''
549+ machine.succeed(
550+ "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
551+ + " mkpart primary 1M 2048M" # PV1
552+ + " set 1 lvm on"
553+ + " mkpart primary 2048M -1s" # PV2
554+ + " set 2 lvm on",
555+ "udevadm settle",
556+ "pvcreate /dev/vda1 /dev/vda2",
557+ "vgcreate MyVolGroup /dev/vda1 /dev/vda2",
558+ "lvcreate --size 1G --name swap MyVolGroup",
559+ "lvcreate --size 2G --name nixos MyVolGroup",
560+ "mkswap -f /dev/MyVolGroup/swap -L swap",
561+ "swapon -L swap",
562+ "mkfs.xfs -L nixos /dev/MyVolGroup/nixos",
563+ "mount LABEL=nixos /mnt",
564+ )
565+ '';
566+ };
547567
548568 # Boot off an encrypted root partition with the default LUKS header format
549569 luksroot = makeLuksRootTest "luksroot-format1" "";
@@ -557,14 +577,14 @@ in {
557577 # Test whether opening encrypted filesystem with keyfile
558578 # Checks for regression of missing cryptsetup, when no luks device without
559579 # keyfile is configured
560− encryptedFSWithKeyfile = makeInstallerTest "encryptedFSWithKeyfile"
561− { createPartitions = ''
562− $machine->succeed(
580+ encryptedFSWithKeyfile = makeInstallerTest "encryptedFSWithKeyfile" {
581+ createPartitions = ''
582+ machine.succeed(
563583 "flock /dev/vda parted --script /dev/vda -- mklabel msdos"
564− . " mkpart primary ext2 1M 50MB" # /boot
565− . " mkpart primary linux-swap 50M 1024M"
566− . " mkpart primary 1024M 1280M" # LUKS with keyfile
567− . " mkpart primary 1280M -1s",
584+ + " mkpart primary ext2 1M 50MB" # /boot
585+ + " mkpart primary linux-swap 50M 1024M"
586+ + " mkpart primary 1024M 1280M" # LUKS with keyfile
587+ + " mkpart primary 1280M -1s",
568588 "udevadm settle",
569589 "mkswap /dev/vda2 -L swap",
570590 "swapon -L swap",
@@ -579,89 +599,88 @@ in {
579599 "cryptsetup luksOpen --key-file /mnt/keyfile /dev/vda3 crypt",
580600 "mkfs.ext3 -L test /dev/mapper/crypt",
581601 "cryptsetup luksClose crypt",
582− "mkdir -p /mnt/test"
583− );
584− '';
585− extraConfig = ''
586− fileSystems."/test" =
587− { device = "/dev/disk/by-label/test";
588− fsType = "ext3";
589− encrypted.enable = true;
590− encrypted.blkDev = "/dev/vda3";
591− encrypted.label = "crypt";
592− encrypted.keyFile = "/mnt-root/keyfile";
593− };
594− '';
595− };
596−
602+ "mkdir -p /mnt/test",
603+ )
604+ '';
605+ extraConfig = ''
606+ fileSystems."/test" = {
607+ device = "/dev/disk/by-label/test";
608+ fsType = "ext3";
609+ encrypted.enable = true;
610+ encrypted.blkDev = "/dev/vda3";
611+ encrypted.label = "crypt";
612+ encrypted.keyFile = "/mnt-root/keyfile";
613+ };
614+ '';
615+ };
597616
598− swraid = makeInstallerTest "swraid"
599− { createPartitions =
600− ''
601− $machine->succeed(
602− "flock /dev/vda parted --script /dev/vda --"
603− . " mklabel msdos"
604− . " mkpart primary ext2 1M 100MB" # /boot
605− . " mkpart extended 100M -1s"
606− . " mkpart logical 102M 2102M" # md0 (root), first device
607− . " mkpart logical 2103M 4103M" # md0 (root), second device
608− . " mkpart logical 4104M 4360M" # md1 (swap), first device
609− . " mkpart logical 4361M 4617M", # md1 (swap), second device
610− "udevadm settle",
611− "ls -l /dev/vda* >&2",
612− "cat /proc/partitions >&2",
613− "udevadm control --stop-exec-queue",
614− "mdadm --create --force /dev/md0 --metadata 1.2 --level=raid1 --raid-devices=2 /dev/vda5 /dev/vda6",
615− "mdadm --create --force /dev/md1 --metadata 1.2 --level=raid1 --raid-devices=2 /dev/vda7 /dev/vda8",
616− "udevadm control --start-exec-queue",
617− "udevadm settle",
618− "mkswap -f /dev/md1 -L swap",
619− "swapon -L swap",
620− "mkfs.ext3 -L nixos /dev/md0",
621− "mount LABEL=nixos /mnt",
622− "mkfs.ext3 -L boot /dev/vda1",
623− "mkdir /mnt/boot",
624− "mount LABEL=boot /mnt/boot",
625− "udevadm settle",
626− );
627− '';
628− preBootCommands = ''
629− $machine->start;
630− $machine->fail("dmesg | grep 'immediate safe mode'");
631− '';
632− };
617+ swraid = makeInstallerTest "swraid" {
618+ createPartitions = ''
619+ machine.succeed(
620+ "flock /dev/vda parted --script /dev/vda --"
621+ + " mklabel msdos"
622+ + " mkpart primary ext2 1M 100MB" # /boot
623+ + " mkpart extended 100M -1s"
624+ + " mkpart logical 102M 2102M" # md0 (root), first device
625+ + " mkpart logical 2103M 4103M" # md0 (root), second device
626+ + " mkpart logical 4104M 4360M" # md1 (swap), first device
627+ + " mkpart logical 4361M 4617M", # md1 (swap), second device
628+ "udevadm settle",
629+ "ls -l /dev/vda* >&2",
630+ "cat /proc/partitions >&2",
631+ "udevadm control --stop-exec-queue",
632+ "mdadm --create --force /dev/md0 --metadata 1.2 --level=raid1 "
633+ + "--raid-devices=2 /dev/vda5 /dev/vda6",
634+ "mdadm --create --force /dev/md1 --metadata 1.2 --level=raid1 "
635+ + "--raid-devices=2 /dev/vda7 /dev/vda8",
636+ "udevadm control --start-exec-queue",
637+ "udevadm settle",
638+ "mkswap -f /dev/md1 -L swap",
639+ "swapon -L swap",
640+ "mkfs.ext3 -L nixos /dev/md0",
641+ "mount LABEL=nixos /mnt",
642+ "mkfs.ext3 -L boot /dev/vda1",
643+ "mkdir /mnt/boot",
644+ "mount LABEL=boot /mnt/boot",
645+ "udevadm settle",
646+ )
647+ '';
648+ preBootCommands = ''
649+ machine.start()
650+ machine.fail("dmesg | grep 'immediate safe mode'")
651+ '';
652+ };
633653
634654 # Test a basic install using GRUB 1.
635− grub1 = makeInstallerTest "grub1"
636− { createPartitions =
637− ''
638− $machine->succeed(
639− "flock /dev/sda parted --script /dev/sda -- mklabel msdos"
640− . " mkpart primary linux-swap 1M 1024M"
641− . " mkpart primary ext2 1024M -1s",
642− "udevadm settle",
643− "mkswap /dev/sda1 -L swap",
644− "swapon -L swap",
645− "mkfs.ext3 -L nixos /dev/sda2",
646− "mount LABEL=nixos /mnt",
647− "mkdir -p /mnt/tmp",
648− );
649− '';
650− grubVersion = 1;
651− grubDevice = "/dev/sda";
652− };
655+ grub1 = makeInstallerTest "grub1" {
656+ createPartitions = ''
657+ machine.succeed(
658+ "flock /dev/sda parted --script /dev/sda -- mklabel msdos"
659+ + " mkpart primary linux-swap 1M 1024M"
660+ + " mkpart primary ext2 1024M -1s",
661+ "udevadm settle",
662+ "mkswap /dev/sda1 -L swap",
663+ "swapon -L swap",
664+ "mkfs.ext3 -L nixos /dev/sda2",
665+ "mount LABEL=nixos /mnt",
666+ "mkdir -p /mnt/tmp",
667+ )
668+ '';
669+ grubVersion = 1;
670+ grubDevice = "/dev/sda";
671+ };
653672
654673 # Test using labels to identify volumes in grub
655674 simpleLabels = makeInstallerTest "simpleLabels" {
656675 createPartitions = ''
657− $machine->succeed(
658− "sgdisk -Z /dev/vda",
659− "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
660− "mkswap /dev/vda2 -L swap",
661− "swapon -L swap",
662− "mkfs.ext4 -L root /dev/vda3",
663− "mount LABEL=root /mnt",
664− );
676+ machine.succeed(
677+ "sgdisk -Z /dev/vda",
678+ "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
679+ "mkswap /dev/vda2 -L swap",
680+ "swapon -L swap",
681+ "mkfs.ext4 -L root /dev/vda3",
682+ "mount LABEL=root /mnt",
683+ )
665684 '';
666685 grubIdentifier = "label";
667686 };
@@ -670,22 +689,23 @@ in {
670689 # TODO: Fix udev so the symlinks are unneeded in /dev/disks
671690 simpleProvided = makeInstallerTest "simpleProvided" {
672691 createPartitions = ''
673− my $UUID = "\$(blkid -s UUID -o value /dev/vda2)";
674− $machine->succeed(
675− "sgdisk -Z /dev/vda",
676− "sgdisk -n 1:0:+1M -n 2:0:+100M -n 3:0:+1G -N 4 -t 1:ef02 -t 2:8300 -t 3:8200 -t 4:8300 -c 2:boot -c 4:root /dev/vda",
677− "mkswap /dev/vda3 -L swap",
678− "swapon -L swap",
679− "mkfs.ext4 -L boot /dev/vda2",
680− "mkfs.ext4 -L root /dev/vda4",
681− );
682− $machine->execute("ln -s ../../vda2 /dev/disk/by-uuid/$UUID");
683− $machine->execute("ln -s ../../vda4 /dev/disk/by-label/root");
684− $machine->succeed(
685− "mount /dev/disk/by-label/root /mnt",
686− "mkdir /mnt/boot",
687− "mount /dev/disk/by-uuid/$UUID /mnt/boot"
688− );
692+ uuid = "$(blkid -s UUID -o value /dev/vda2)"
693+ machine.succeed(
694+ "sgdisk -Z /dev/vda",
695+ "sgdisk -n 1:0:+1M -n 2:0:+100M -n 3:0:+1G -N 4 -t 1:ef02 -t 2:8300 "
696+ + "-t 3:8200 -t 4:8300 -c 2:boot -c 4:root /dev/vda",
697+ "mkswap /dev/vda3 -L swap",
698+ "swapon -L swap",
699+ "mkfs.ext4 -L boot /dev/vda2",
700+ "mkfs.ext4 -L root /dev/vda4",
701+ )
702+ machine.execute(f"ln -s ../../vda2 /dev/disk/by-uuid/{uuid}")
703+ machine.execute("ln -s ../../vda4 /dev/disk/by-label/root")
704+ machine.succeed(
705+ "mount /dev/disk/by-label/root /mnt",
706+ "mkdir /mnt/boot",
707+ f"mount /dev/disk/by-uuid/{uuid} /mnt/boot",
708+ )
689709 '';
690710 grubIdentifier = "provided";
691711 };
@@ -693,61 +713,62 @@ in {
693713 # Simple btrfs grub testing
694714 btrfsSimple = makeInstallerTest "btrfsSimple" {
695715 createPartitions = ''
696− $machine->succeed(
697− "sgdisk -Z /dev/vda",
698− "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
699− "mkswap /dev/vda2 -L swap",
700− "swapon -L swap",
701− "mkfs.btrfs -L root /dev/vda3",
702− "mount LABEL=root /mnt",
703− );
716+ machine.succeed(
717+ "sgdisk -Z /dev/vda",
718+ "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
719+ "mkswap /dev/vda2 -L swap",
720+ "swapon -L swap",
721+ "mkfs.btrfs -L root /dev/vda3",
722+ "mount LABEL=root /mnt",
723+ )
704724 '';
705725 };
706726
707727 # Test to see if we can detect /boot and /nix on subvolumes
708728 btrfsSubvols = makeInstallerTest "btrfsSubvols" {
709729 createPartitions = ''
710− $machine->succeed(
711− "sgdisk -Z /dev/vda",
712− "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
713− "mkswap /dev/vda2 -L swap",
714− "swapon -L swap",
715− "mkfs.btrfs -L root /dev/vda3",
716− "btrfs device scan",
717− "mount LABEL=root /mnt",
718− "btrfs subvol create /mnt/boot",
719− "btrfs subvol create /mnt/nixos",
720− "btrfs subvol create /mnt/nixos/default",
721− "umount /mnt",
722− "mount -o defaults,subvol=nixos/default LABEL=root /mnt",
723− "mkdir /mnt/boot",
724− "mount -o defaults,subvol=boot LABEL=root /mnt/boot",
725− );
730+ machine.succeed(
731+ "sgdisk -Z /dev/vda",
732+ "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
733+ "mkswap /dev/vda2 -L swap",
734+ "swapon -L swap",
735+ "mkfs.btrfs -L root /dev/vda3",
736+ "btrfs device scan",
737+ "mount LABEL=root /mnt",
738+ "btrfs subvol create /mnt/boot",
739+ "btrfs subvol create /mnt/nixos",
740+ "btrfs subvol create /mnt/nixos/default",
741+ "umount /mnt",
742+ "mount -o defaults,subvol=nixos/default LABEL=root /mnt",
743+ "mkdir /mnt/boot",
744+ "mount -o defaults,subvol=boot LABEL=root /mnt/boot",
745+ )
726746 '';
727747 };
728748
729749 # Test to see if we can detect default and aux subvolumes correctly
730750 btrfsSubvolDefault = makeInstallerTest "btrfsSubvolDefault" {
731751 createPartitions = ''
732− $machine->succeed(
733− "sgdisk -Z /dev/vda",
734− "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
735− "mkswap /dev/vda2 -L swap",
736− "swapon -L swap",
737− "mkfs.btrfs -L root /dev/vda3",
738− "btrfs device scan",
739− "mount LABEL=root /mnt",
740− "btrfs subvol create /mnt/badpath",
741− "btrfs subvol create /mnt/badpath/boot",
742− "btrfs subvol create /mnt/nixos",
743− "btrfs subvol set-default \$(btrfs subvol list /mnt | grep 'nixos' | awk '{print \$2}') /mnt",
744− "umount /mnt",
745− "mount -o defaults LABEL=root /mnt",
746− "mkdir -p /mnt/badpath/boot", # Help ensure the detection mechanism is actually looking up subvolumes
747− "mkdir /mnt/boot",
748− "mount -o defaults,subvol=badpath/boot LABEL=root /mnt/boot",
749− );
752+ machine.succeed(
753+ "sgdisk -Z /dev/vda",
754+ "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
755+ "mkswap /dev/vda2 -L swap",
756+ "swapon -L swap",
757+ "mkfs.btrfs -L root /dev/vda3",
758+ "btrfs device scan",
759+ "mount LABEL=root /mnt",
760+ "btrfs subvol create /mnt/badpath",
761+ "btrfs subvol create /mnt/badpath/boot",
762+ "btrfs subvol create /mnt/nixos",
763+ "btrfs subvol set-default "
764+ + "$(btrfs subvol list /mnt | grep 'nixos' | awk '{print \$2}') /mnt",
765+ "umount /mnt",
766+ "mount -o defaults LABEL=root /mnt",
767+ "mkdir -p /mnt/badpath/boot", # Help ensure the detection mechanism
768+ # is actually looking up subvolumes
769+ "mkdir /mnt/boot",
770+ "mount -o defaults,subvol=badpath/boot LABEL=root /mnt/boot",
771+ )
750772 '';
751773 };
752−
753774}