diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-02 22:46:50 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-02 23:13:38 +0200 |
commit | 9a80695caad3ae146b4232c6b295ce0fc75a6c19 (patch) | |
tree | 22062630c4b5800a132851f718742b9e43eae85c /tests.nix | |
parent | feat(hosts/server1): Activate the migrated services (diff) | |
download | nixos-server-9a80695caad3ae146b4232c6b295ce0fc75a6c19.tar.gz nixos-server-9a80695caad3ae146b4232c6b295ce0fc75a6c19.zip |
test(tests): Init infrastructure
The modules still need to be imported one-by-one in `default.nix` files because we have yet to rewrite this, but the new test infrastructure might as well use the new `fileset` functions from `nixpkgs`.
Diffstat (limited to '')
-rw-r--r-- | tests.nix | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests.nix b/tests.nix new file mode 100644 index 0000000..d91a9c9 --- /dev/null +++ b/tests.nix @@ -0,0 +1,28 @@ +{ + pkgs, + lib, + specialArgs, +}: let + # for `nix eval --file` (as it does not support args) use: + # ``` + # specialArgs = {}; + # pkgs = (builtins.getFlake "nixpkgs").legacyPackages."x86_64-linux"; + # inherit (pkgs) lib; + # ``` + # instead of the function arguments above. + importTests' = test: let + basename = builtins.baseNameOf test; + testName = builtins.baseNameOf (lib.strings.removeSuffix "/${basename}" "${builtins.toString test}"); + in { + name = "${testName}"; + value = pkgs.callPackage test specialArgs; + }; + + importTests = dir: + builtins.listToAttrs (builtins.map importTests' ( + lib.fileset.toList (lib.fileset.fileFilter (file: file.name == "test.nix") dir) + )); + + tests = importTests ./tests; +in + tests |