mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Convert all 40 `tests/*.nix` files that previously called
`diskoLib.testLib.makeDiskoTest { … }` into pure NixOS modules. Each
test now imports its corresponding `../example/foo.nix` and sets
`disko.test = { name = …; extraChecks = …; nodes.machine = …; … };`
inline.
Switch `tests/default.nix` to discover the module-style tests via
nixpkgs's `nixos/lib/eval-config.nix` and read
`config.system.build.diskoTest` off each. The four bespoke tests
(`make-disk-image`, `make-disk-image-impure`, `mdadm-btrfs-wipe`,
`standalone`) keep their function-call shape and are still imported
imperatively; they don't fit the example-eval pattern.
Arg-to-option translations performed in each file:
- `extraSystemConfig` → `disko.test.nodes.machine`
- `extraInstallerConfig` → `disko.test.nodes.formatter`
- `bootCommands`/`efi`/`enableOCR`/`postDisko`/`enableCanokey`
/`name` → `disko.test.<same>`
- `extraTestScript` → `disko.test.extraChecks`
- `testBoot` → `disko.test.boot`
- `testMode` → `disko.test.mode` (`cli` and `module` set this
explicitly; the rest use the default `"module"`)
- `extraInstallerConfig.networking.hostId` /
`extraSystemConfig.networking.hostId` → host-level
`networking.hostId` (propagated to every node by module.nix's
`defaults.networking.hostId` in the evalTest call)
`tests/cli.nix` and `tests/module.nix` both import
`../example/complex.nix` and override `disko.test.{name,mode,extraChecks}`
with `lib.mkForce` — those overrides will keep working after commit 8
folds `tests/complex.nix`'s `disko.test` block into
`example/complex.nix`.
`tests/zfs-encrypted-root.nix`'s legacy `pkgs.lib.recursiveUpdate` on
the imported disko-config becomes a flat
`disko.devices.zpool.zroot.datasets.root.options.keylocation = …;`
override — the module system merges nested attrs automatically.
Lost capability: `nix-build tests/luks.nix` standalone-build no
longer works (modules aren't directly buildable). Replace with
`nix build .#checks.<system>.luks`.
22 lines
609 B
Nix
22 lines
609 B
Nix
{ lib, ... }:
|
|
{
|
|
imports = [ ../example/complex.nix ];
|
|
disko.test = {
|
|
name = lib.mkForce "module";
|
|
mode = "module";
|
|
extraChecks = lib.mkForce ''
|
|
machine.succeed("test -b /dev/md/raid1p1");
|
|
machine.succeed("mountpoint /zfs_fs");
|
|
machine.succeed("mountpoint /zfs_legacy_fs");
|
|
machine.succeed("mountpoint /ext4onzfs");
|
|
machine.succeed("mountpoint /ext4_on_lvm");
|
|
'';
|
|
nodes.machine.fileSystems."/zfs_legacy_fs".options = [ "nofail" ];
|
|
nodes.formatter.boot.kernelModules = [
|
|
"dm-raid"
|
|
"dm-mirror"
|
|
];
|
|
};
|
|
networking.hostId = "8425e349";
|
|
}
|