2022-08-17 12:20:44 +00:00
|
|
|
{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
|
|
|
|
, pkgs ? (import <nixpkgs> {})
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
makeTest' = args:
|
|
|
|
makeTest args {
|
|
|
|
inherit pkgs;
|
|
|
|
inherit (pkgs) system;
|
|
|
|
};
|
2022-08-24 14:46:36 +00:00
|
|
|
disko-config = import ../example/raid.nix;
|
2022-08-17 13:54:28 +00:00
|
|
|
tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config);
|
|
|
|
tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config);
|
2022-08-17 12:20:44 +00:00
|
|
|
in makeTest' {
|
2018-08-05 09:45:15 +00:00
|
|
|
name = "disko";
|
|
|
|
|
2022-07-10 07:39:47 +00:00
|
|
|
nodes.machine =
|
2022-08-17 12:20:44 +00:00
|
|
|
{ config, pkgs, modulesPath, ... }:
|
2018-08-05 09:45:15 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
imports = [
|
2022-08-17 12:20:44 +00:00
|
|
|
(modulesPath + "/profiles/installation-device.nix")
|
|
|
|
(modulesPath + "/profiles/base.nix")
|
2018-08-05 09:45:15 +00:00
|
|
|
];
|
|
|
|
|
2022-08-17 12:20:44 +00:00
|
|
|
# speed-up eval
|
|
|
|
documentation.enable = false;
|
|
|
|
|
2022-08-24 14:46:36 +00:00
|
|
|
virtualisation.emptyDiskImages = [ 512 512 ];
|
2018-08-05 09:45:15 +00:00
|
|
|
};
|
|
|
|
|
2022-08-17 12:20:44 +00:00
|
|
|
testScript = ''
|
|
|
|
machine.succeed("echo 'secret' > /tmp/secret.key");
|
2022-08-17 13:54:28 +00:00
|
|
|
machine.succeed("${tsp-create}");
|
|
|
|
machine.succeed("${tsp-mount}");
|
|
|
|
machine.succeed("${tsp-mount}"); # verify that the command is idempotent
|
2022-08-24 14:46:36 +00:00
|
|
|
machine.succeed("test -b /dev/md/raid1");
|
2022-08-17 12:20:44 +00:00
|
|
|
'';
|
|
|
|
}
|