summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-09-30 12:55:28 +0200
committerlassulus <lassulus@lassul.us>2022-10-02 16:41:02 +0200
commit9f7f23abdb161578316d94f45528fbf47982f4d9 (patch)
tree92134db7dbe059a7163571e50045b42798a2aea4
parenta215a1975938fbc04ae8fb14e474304f3200e15c (diff)
add nixos tests for disko.config, extend/fix existing tests
-rw-r--r--example/boot-raid1.nix117
-rw-r--r--example/btrfs-subvolumes.nix19
-rw-r--r--example/complex.nix49
-rw-r--r--example/default.nix14
-rw-r--r--example/gpt-bios-compat.nix4
-rw-r--r--example/luks-lvm.nix6
-rw-r--r--example/lvm-raid.nix50
-rw-r--r--example/mdadm.nix24
-rw-r--r--example/zfs-over-legacy.nix31
-rw-r--r--example/zfs.nix55
-rw-r--r--flake.nix1
-rw-r--r--tests/boot-raid1.nix10
-rw-r--r--tests/btrfs-subvolumes.nix4
-rw-r--r--tests/complex.nix17
-rw-r--r--tests/default.nix3
-rw-r--r--tests/gpt-bios-compat.nix5
-rw-r--r--tests/lib.nix117
-rw-r--r--tests/luks-lvm.nix9
-rw-r--r--tests/lvm-raid.nix4
-rw-r--r--tests/mdadm.nix4
-rw-r--r--tests/zfs-over-legacy.nix5
-rw-r--r--tests/zfs.nix10
22 files changed, 448 insertions, 110 deletions
diff --git a/example/boot-raid1.nix b/example/boot-raid1.nix
new file mode 100644
index 0000000..c930eb5
--- /dev/null
+++ b/example/boot-raid1.nix
@@ -0,0 +1,117 @@
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
+ disk = {
+ one = {
+ type = "disk";
+ device = builtins.elemAt disks 0;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
+ type = "partition";
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
+ type = "partition";
+ name = "mdadm";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "mdraid";
+ name = "raid1";
+ };
+ }
+ ];
+ };
+ };
+ two = {
+ type = "disk";
+ device = builtins.elemAt disks 1;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
+ type = "partition";
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
+ type = "partition";
+ name = "mdadm";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "mdraid";
+ name = "raid1";
+ };
+ }
+ ];
+ };
+ };
+ };
+ mdadm = {
+ boot = {
+ type = "mdadm";
+ level = 1;
+ metadata = "1.0";
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ };
+ raid1 = {
+ type = "mdadm";
+ level = 1;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ type = "partition";
+ name = "primary";
+ start = "1MiB";
+ end = "100%";
+ content = {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
+ }
+ ];
+ };
+ };
+ };
+}
diff --git a/example/btrfs-subvolumes.nix b/example/btrfs-subvolumes.nix
index 83ea71e..9a22861 100644
--- a/example/btrfs-subvolumes.nix
+++ b/example/btrfs-subvolumes.nix
@@ -1,16 +1,29 @@
-{
+{ disks ? [ "/dev/vdb" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ type = "partition";
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ }
+ {
name = "root";
type = "partition";
- start = "0%";
+ start = "128MiB";
end = "100%";
content = {
type = "btrfs";
diff --git a/example/complex.nix b/example/complex.nix
index 078f9c5..7ee9282 100644
--- a/example/complex.nix
+++ b/example/complex.nix
@@ -1,25 +1,40 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
- disk1 = {
+ disk0 = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
- start = "0";
- end = "1M";
- name = "grub";
- flags = ["bios_grub"];
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
}
+ ];
+ };
+ };
+ disk1 = {
+ type = "disk";
+ device = builtins.elemAt disks 1;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
{
type = "partition";
start = "1M";
end = "100%";
name = "luks";
- bootable = true;
content = {
type = "luks";
name = "crypted1";
@@ -39,24 +54,16 @@
};
disk2 = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 2;
content = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
- start = "0";
- end = "1M";
- name = "grub";
- flags = ["bios_grub"];
- }
- {
- type = "partition";
start = "1M";
end = "100%";
name = "luks";
- bootable = true;
content = {
type = "luks";
name = "crypted2";
@@ -81,17 +88,17 @@
level = 1;
content = {
type = "table";
- format = "msdos";
+ format = "gpt";
partitions = [
{
type = "partition";
- name = "xfs";
+ name = "bla";
start = "1MiB";
end = "100%";
content = {
type = "filesystem";
- format = "xfs";
- mountpoint = "/xfs_mdadm_lvm";
+ format = "ext4";
+ mountpoint = "/ext4_mdadm_lvm";
};
}
];
diff --git a/example/default.nix b/example/default.nix
deleted file mode 100644
index e69c8db..0000000
--- a/example/default.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-# usage: nix-instantiate --eval --json --strict example | jq -r .
-
-let
- cfg = import ./config.nix;
- #cfg = import ./config-gpt-bios.nix;
-in
-# TODO: get rid of NIX_PATH dependency here
-with import ../. {};
-
-{
- config = config cfg;
- create = create cfg;
- mount = mount cfg;
-}
diff --git a/example/gpt-bios-compat.nix b/example/gpt-bios-compat.nix
index 9abe691..72886a0 100644
--- a/example/gpt-bios-compat.nix
+++ b/example/gpt-bios-compat.nix
@@ -1,8 +1,8 @@
# Example to create a bios compatible gpt partition
-{
+{ disks ? [ "/dev/vdb" ] }: {
disk = {
vdb = {
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
type = "disk";
content = {
type = "table";
diff --git a/example/luks-lvm.nix b/example/luks-lvm.nix
index 17e18a2..fdaba8c 100644
--- a/example/luks-lvm.nix
+++ b/example/luks-lvm.nix
@@ -1,8 +1,8 @@
-{
+{ disks ? [ "/dev/vdb" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
@@ -10,7 +10,6 @@
{
type = "partition";
name = "ESP";
- # fs-type = "FAT32";
start = "1MiB";
end = "100MiB";
bootable = true;
@@ -34,7 +33,6 @@
keyFile = "/tmp/secret.key";
extraArgs = [
"--hash sha512"
- "--iter-time 5000"
];
content = {
type = "lvm_pv";
diff --git a/example/lvm-raid.nix b/example/lvm-raid.nix
index 3c5ee69..9d0c9d7 100644
--- a/example/lvm-raid.nix
+++ b/example/lvm-raid.nix
@@ -1,16 +1,28 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
- vdb = {
+ one = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "100M";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
type = "partition";
name = "primary";
- start = "0%";
+ start = "100M";
end = "100%";
content = {
type = "lvm_pv";
@@ -20,17 +32,29 @@
];
};
};
- vdc = {
+ two = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "100M";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
type = "partition";
name = "primary";
- start = "0%";
+ start = "100M";
end = "100%";
content = {
type = "lvm_pv";
@@ -41,6 +65,18 @@
};
};
};
+ mdadm = {
+ boot = {
+ type = "mdadm";
+ level = 1;
+ metadata = "1.0";
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ };
+ };
lvm_vg = {
pool = {
type = "lvm_vg";
diff --git a/example/mdadm.nix b/example/mdadm.nix
index 094499d..8093698 100644
--- a/example/mdadm.nix
+++ b/example/mdadm.nix
@@ -1,13 +1,21 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
type = "partition";
name = "mdadm";
start = "1MiB";
@@ -22,12 +30,20 @@
};
vdc = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
type = "partition";
name = "mdadm";
start = "1MiB";
@@ -57,7 +73,7 @@
content = {
type = "filesystem";
format = "ext4";
- mountpoint = "/raid";
+ mountpoint = "/";
};
}
];
diff --git a/example/zfs-over-legacy.nix b/example/zfs-over-legacy.nix
index 81a5975..9943278 100644
--- a/example/zfs-over-legacy.nix
+++ b/example/zfs-over-legacy.nix
@@ -1,15 +1,30 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
- start = "0%";
+ name = "ESP";
+ start = "1MiB";
+ end = "100MiB";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ options = [
+ "defaults"
+ ];
+ };
+ }
+ {
+ type = "partition";
+ start = "100MiB";
end = "100%";
name = "primary";
bootable = true;
@@ -24,7 +39,7 @@
};
vdc = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
type = "zfs";
pool = "zroot";
@@ -34,10 +49,16 @@
zpool = {
zroot = {
type = "zpool";
+ rootFsOptions.mountpoint = "none";
datasets = {
- zfs_fs = {
+ "root" = {
+ zfs_type = "filesystem";
+ options.mountpoint = "none";
+ };
+ "root/zfs_fs" = {
zfs_type = "filesystem";
mountpoint = "/zfs_fs";
+ options.mountpoint = "/zfs_fs";
options."com.sun:auto-snapshot" = "true";
};
};
diff --git a/example/zfs.nix b/example/zfs.nix
index 16da367..92ed688 100644
--- a/example/zfs.nix
+++ b/example/zfs.nix
@@ -1,19 +1,56 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
- vdb = {
+ x = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
- type = "zfs";
- pool = "zroot";
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ type = "partition";
+ name = "ESP";
+ start = "0";
+ end = "64MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ }
+ {
+ type = "partition";
+ name = "zfs";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "zfs";
+ pool = "zroot";
+ };
+ }
+ ];
};
};
- vdc = {
+ y = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
- type = "zfs";
- pool = "zroot";
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ type = "partition";
+ name = "zfs";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "zfs";
+ pool = "zroot";
+ };
+ }
+ ];
};
};
};
diff --git a/flake.nix b/flake.nix
index 488933d..cdc5a4c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -14,6 +14,7 @@
import ./tests {
inherit pkgs;
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
+ eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
};
};
}
diff --git a/tests/boot-raid1.nix b/tests/boot-raid1.nix
new file mode 100644
index 0000000..6d0a563
--- /dev/null
+++ b/tests/boot-raid1.nix
@@ -0,0 +1,10 @@
+{ pkgs ? (import <nixpkgs> { })
+, makeDiskoTest ? (pkgs.callPackage ./lib.nix { }).makeDiskoTest
+}:
+makeDiskoTest {
+ disko-config = import ../example/boot-raid1.nix;
+ extraTestScript = ''
+ machine.succeed("test -b /dev/md/boot");
+ machine.succeed("mountpoint /boot");
+ '';
+}
diff --git a/tests/btrfs-subvolumes.nix b/tests/btrfs-subvolumes.nix
index 3ff4386..e53cf34 100644
--- a/tests/btrfs-subvolumes.nix
+++ b/tests/btrfs-subvolumes.nix
@@ -4,8 +4,8 @@
makeDiskoTest {
disko-config = import ../example/btrfs-subvolumes.nix;
extraTestScript = ''
- machine.succeed("test -e /mnt/test");
- machine.succeed("btrfs subvolume list /mnt | grep -qs 'path test$'");
+ machine.succeed("test -e /test");
+ machine.succeed("btrfs subvolume list / | grep -qs 'path test$'");
'';
}
diff --git a/tests/complex.nix b/tests/complex.nix
index 3fa861e..cd87b3b 100644
--- a/tests/complex.nix
+++ b/tests/complex.nix
@@ -3,16 +3,23 @@
}:
makeDiskoTest {
disko-config = import ../example/complex.nix;
+ extraConfig = {
+ fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
+ };
extraTestScript = ''
machine.succeed("test -b /dev/zroot/zfs_testvolume");
machine.succeed("test -b /dev/md/raid1p1");
- machine.succeed("mountpoint /mnt");
- machine.succeed("mountpoint /mnt/zfs_fs");
- machine.succeed("mountpoint /mnt/zfs_legacy_fs");
- machine.succeed("mountpoint /mnt/ext4onzfs");
- machine.succeed("mountpoint /mnt/ext4_on_lvm");
+ machine.succeed("mountpoint /zfs_fs");
+ machine.succeed("mountpoint /zfs_legacy_fs");
+ machine.succeed("mountpoint /ext4onzfs");
+ machine.succeed("mountpoint /ext4_on_lvm");
+ '';
+ enableOCR = true;
+ bootCommands = ''
+ machine.wait_for_text("Passphrase for")
+ machine.send_chars("secret\n")
'';
extraConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ];
diff --git a/tests/default.nix b/tests/default.nix
index 496a935..c10cf76 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -1,9 +1,10 @@
{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
+, eval-config ? import <nixpkgs/nixos/lib/eval-config.nix>
, pkgs ? (import <nixpkgs> { })
}@args:
let
lib = pkgs.lib;
- makeDiskoTest = (pkgs.callPackage ./lib.nix { inherit makeTest; }).makeDiskoTest;
+ makeDiskoTest = (pkgs.callPackage ./lib.nix { inherit makeTest eval-config; }).makeDiskoTest;
evalTest = name: configFile: let
disko-config = import configFile;
diff --git a/tests/gpt-bios-compat.nix b/tests/gpt-bios-compat.nix
index df35335..d9317f9 100644
--- a/tests/gpt-bios-compat.nix
+++ b/tests/gpt-bios-compat.nix
@@ -4,7 +4,8 @@
makeDiskoTest {
disko-config = import ../example/gpt-bios-compat.nix;
extraTestScript = ''
- machine.succeed("mountpoint /mnt");
- machine.succeed("grub-install --target=i386-pc /dev/vdb");
+ machine.succeed("mountpoint /");
'';
+ efi = false;
+ grub-devices = [ "/dev/vdb" ];
}
diff --git a/tests/lib.nix b/tests/lib.nix
index 0bcba2b..fb9d1e9 100644
--- a/tests/lib.nix
+++ b/tests/lib.nix
@@ -1,12 +1,17 @@
{ pkgs ? (import <nixpkgs> { })
, makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
+, eval-config ? import <nixpkgs/nixos/lib/eval-config.nix>
, ...
}:
{
makeDiskoTest =
{ disko-config
- , extraTestScript
+ , extraTestScript ? ""
+ , bootCommands ? ""
, extraConfig ? { }
+ , grub-devices ? [ "nodev" ]
+ , efi ? true
+ , enableOCR ? false
}:
let
lib = pkgs.lib;
@@ -15,33 +20,107 @@
inherit pkgs;
inherit (pkgs) system;
};
- tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config);
- tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config);
- num-disks = builtins.length (lib.attrNames disko-config.disk);
+ disks = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" ];
+ tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create (disko-config { disks = builtins.tail disks; }));
+ tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount (disko-config { disks = builtins.tail disks; }));
+ tsp-config = (pkgs.callPackage ../. { }).config (disko-config { inherit disks; });
+ num-disks = builtins.length (lib.attrNames (disko-config {}).disk);
+ installed-system = { modulesPath, ... }: {
+ imports = [
+ tsp-config
+ (modulesPath + "/testing/test-instrumentation.nix")
+ (modulesPath + "/profiles/qemu-guest.nix")
+ (modulesPath + "/profiles/minimal.nix")
+ extraConfig
+ ];
+ fileSystems."/nix/store" = {
+ device = "nix-store";
+ fsType = "9p";
+ neededForBoot = true;
+ options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ];
+ };
+ documentation.enable = false;
+ hardware.enableAllFirmware = lib.mkForce false;
+ networking.hostId = "8425e349"; # from profiles/base.nix, needed for zfs
+ boot.kernelParams = lib.mkAfter [ "console=tty0" ]; # needed to have serial interaction during boot
+ boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
+
+ boot.consoleLogLevel = lib.mkForce 100;
+ boot.loader.grub = {
+ devices = grub-devices;
+ efiSupport = efi;
+ efiInstallAsRemovable = efi;
+ };
+ };
+ installedTopLevel = (eval-config {
+ modules = [ installed-system ];
+ system = "x86_64-linux";
+ }).config.system.build.toplevel;
in
makeTest' {
name = "disko";
- nodes.machine =
- { config, pkgs, modulesPath, ... }:
+ inherit enableOCR;
+ nodes.machine = { config, pkgs, modulesPath, ... }: {
+ imports = [
+ (modulesPath + "/profiles/base.nix")
+ (modulesPath + "/profiles/minimal.nix")
+ extraConfig
+ ];
- {
- imports = [
- (modulesPath + "/profiles/installation-device.nix")
- (modulesPath + "/profiles/base.nix")
- ];
+ # speed-up eval
+ documentation.enable = false;
- # speed-up eval
- documentation.enable = false;
+ nix.settings = {
+ substituters = lib.mkForce [];
+ hashed-mirrors = null;
+ connect-timeout = 1;
+ };
- virtualisation.emptyDiskImages = builtins.genList (_: 512) num-disks;
- } // extraConfig;
+ virtualisation.emptyDiskImages = builtins.genList (_: 4096) num-disks;
+ };
testScript = ''
- machine.succeed("echo 'secret' > /tmp/secret.key");
- machine.succeed("${tsp-create}");
- machine.succeed("${tsp-mount}");
- machine.succeed("${tsp-mount}"); # verify that the command is idempotent
+ def disks(oldmachine, num_disks):
+ disk_flags = ""
+ for i in range(num_disks):
+ disk_flags += f' -drive file={oldmachine.state_dir}/empty{i}.qcow2,id=drive{i + 1},if=none,index={i + 1},werror=report'
+ disk_flags += f' -device virtio-blk-pci,drive=drive{i + 1}'
+ return disk_flags
+ def create_test_machine(oldmachine=None, args={}): # taken from <nixpkgs/nixos/tests/installer.nix>
+ machine = create_machine({
+ "qemuFlags": "-cpu max -m 1024 -virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store" + disks(oldmachine, ${toString num-disks}),
+ ${lib.optionalString efi ''"bios": "${pkgs.OVMF.fd}/FV/OVMF.fd",''}
+ } | args)
+ driver.machines.append(machine)
+ return machine
+
+ machine.start()
+ machine.succeed("echo -n 'secret' > /tmp/secret.key")
+ machine.succeed("${tsp-create}")
+ machine.succeed("${tsp-mount}")
+ machine.succeed("${tsp-mount}") # verify that the command is idempotent
+
+ # mount nix-store in /mnt
+ machine.succeed("mkdir -p /mnt/nix/store")
+ machine.succeed("mount --bind /nix/store /mnt/nix/store")
+
+ machine.succeed("nix-store --load-db < ${pkgs.closureInfo {rootPaths = [installedTopLevel];}}/registration")
+
+ # fix "this is not a NixOS installation"
+ machine.succeed("mkdir -p /mnt/etc")
+ machine.succeed("touch /mnt/etc/NIXOS")
+
+ machine.succeed("mkdir -p /mnt/nix/var/nix/profiles")
+ machine.succeed("nix-env -p /mnt/nix/var/nix/profiles/system --set ${installedTopLevel}")
+ machine.succeed("NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root /mnt -- ${installedTopLevel}/bin/switch-to-configuration boot")
+ machine.succeed("sync")
+ machine.shutdown()
+
+ machine = create_test_machine(oldmachine=machine, args={ "name": "booted_machine" })
+ machine.start()
+ ${bootCommands}
+ machine.wait_for_unit("local-fs.target")
${extraTestScript}
'';
};
diff --git a/tests/luks-lvm.nix b/tests/luks-lvm.nix
index d59f3f4..1a3dc66 100644
--- a/tests/luks-lvm.nix
+++ b/tests/luks-lvm.nix
@@ -4,7 +4,12 @@
makeDiskoTest {
disko-config = import ../example/luks-lvm.nix;
extraTestScript = ''
- machine.succeed("cryptsetup isLuks /dev/vdb2");
- machine.succeed("mountpoint /mnt/home");
+ machine.succeed("cryptsetup isLuks /dev/vda2");
+ machine.succeed("mountpoint /home");
+ '';
+ enableOCR = true;
+ bootCommands = ''
+ machine.wait_for_text("Passphrase for")
+ machine.send_chars("secret\n")
'';
}
diff --git a/tests/lvm-raid.nix b/tests/lvm-raid.nix
index 102dcd7..1249b7b 100644
--- a/tests/lvm-raid.nix
+++ b/tests/lvm-raid.nix
@@ -4,9 +4,9 @@
makeDiskoTest {
disko-config = import ../example/lvm-raid.nix;
extraTestScript = ''
- machine.succeed("mountpoint /mnt/home");
+ machine.succeed("mountpoint /home");
'';
extraConfig = {
- boot.kernelModules = [ "dm-raid" "dm-mirror" ];
+ boot.kernelModules = [ "dm-raid0" "dm-mirror" ];
};
}
diff --git a/tests/mdadm.nix b/tests/mdadm.nix
index bd57a00..74a7d5d 100644
--- a/tests/mdadm.nix
+++ b/tests/mdadm.nix
@@ -5,6 +5,8 @@ makeDiskoTest {
disko-config = import ../example/mdadm.nix;
extraTestScript = ''
machine.succeed("test -b /dev/md/raid1");
- machine.succeed("mountpoint /mnt/raid");
+ machine.succeed("mountpoint /");
'';
+ efi = false;
+ grub-devices = [ "/dev/vdb" "/dev/vdc" ];
}
diff --git a/tests/zfs-over-legacy.nix b/tests/zfs-over-legacy.nix
index 13f86a9..50e3796 100644
--- a/tests/zfs-over-legacy.nix
+++ b/tests/zfs-over-legacy.nix
@@ -4,9 +4,8 @@
makeDiskoTest {
disko-config = import ../example/zfs-over-legacy.nix;
extraTestScript = ''
- machine.succeed("test -e /mnt/zfs_fs");
- machine.succeed("mountpoint /mnt");
- machine.succeed("mountpoint /mnt/zfs_fs");
+ machine.succeed("test -e /zfs_fs");
+ machine.succeed("mountpoint /zfs_fs");
'';
}
diff --git a/tests/zfs.nix b/tests/zfs.nix
index 5940c4d..78b64bd 100644
--- a/tests/zfs.nix
+++ b/tests/zfs.nix
@@ -3,6 +3,9 @@
}:
makeDiskoTest {
disko-config = import ../example/zfs.nix;
+ extraConfig = {
+ fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
+ };
extraTestScript = ''
machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");
@@ -19,9 +22,8 @@ makeDiskoTest {
assert_property("zroot/zfs_testvolume", "volsize", "10M")
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
- machine.succeed("mountpoint /mnt");
- machine.succeed("mountpoint /mnt/zfs_fs");
- machine.succeed("mountpoint /mnt/zfs_legacy_fs");
- machine.succeed("mountpoint /mnt/ext4onzfs");
+ machine.succeed("mountpoint /zfs_fs");
+ machine.succeed("mountpoint /zfs_legacy_fs");
+ machine.succeed("mountpoint /ext4onzfs");
'';
}