summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-08-17 14:20:44 +0200
committerJörg Thalheim <joerg@thalheim.io>2022-08-17 14:53:43 +0200
commit20bfa327503ca1d89ba26e621a0f588b5449b302 (patch)
tree128f1ce8585c38685a30defbe49de525357e2a97 /tests
parent2fc06462ce5c31d363686b110b42d653b6f8f366 (diff)
disko: get rid of impure imports
This is a backwards-incompatible change but it allows to pin nixpkgs, which is desirable especially in professional environments where reproduciblity is important.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.nix39
1 files changed, 23 insertions, 16 deletions
diff --git a/tests/test.nix b/tests/test.nix
index 76bc5ea..fa89208 100644
--- a/tests/test.nix
+++ b/tests/test.nix
@@ -1,5 +1,12 @@
-import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, ... }: let
-
+{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
+, pkgs ? (import <nixpkgs> {})
+}:
+let
+ makeTest' = args:
+ makeTest args {
+ inherit pkgs;
+ inherit (pkgs) system;
+ };
disko-config = {
type = "devices";
content = {
@@ -78,28 +85,28 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, ... }: let
};
};
};
-
-in {
+in makeTest' {
name = "disko";
nodes.machine =
- { config, pkgs, ... }:
+ { config, pkgs, modulesPath, ... }:
{
imports = [
- <nixpkgs/nixos/modules/profiles/installation-device.nix>
- <nixpkgs/nixos/modules/profiles/base.nix>
+ (modulesPath + "/profiles/installation-device.nix")
+ (modulesPath + "/profiles/base.nix")
];
+ # speed-up eval
+ documentation.enable = false;
+
virtualisation.emptyDiskImages = [ 512 ];
};
- testScript =
- ''
- machine.succeed("echo 'secret' > /tmp/secret.key");
- machine.succeed("${pkgs.writeScript "create" ((import ../lib).create disko-config)}");
- machine.succeed("${pkgs.writeScript "mount" ((import ../lib).mount disko-config)}");
- machine.succeed("test -b /dev/mapper/pool-raw");
- '';
-
-})
+ testScript = ''
+ machine.succeed("echo 'secret' > /tmp/secret.key");
+ machine.succeed("${pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config)}");
+ machine.succeed("${pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config)}");
+ machine.succeed("test -b /dev/mapper/pool-raw");
+ '';
+}