aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-01-20 15:32:31 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-01-20 16:23:52 +0100
commit261c25601d9a4efd5245e3ef161fb52bf0543083 (patch)
tree96558cc1ad6efeb7c03255b46eb2768d30216359 /flake.nix
parent74026bb1014460d511534da8a955bee6948716ee (diff)
Use the official, documented NixOS runTest interface
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix55
1 files changed, 20 insertions, 35 deletions
diff --git a/flake.nix b/flake.nix
index 0dc8c4c2e..31d7f1fcf 100644
--- a/flake.nix
+++ b/flake.nix
@@ -401,6 +401,18 @@
};
};
+ nixos-lib = import (nixpkgs + "/nixos/lib") { };
+
+ # https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
+ runNixOSTestFor = system: test: nixos-lib.runTest {
+ imports = [ test ];
+ hostPkgs = nixpkgsFor.${system};
+ defaults = {
+ nixpkgs.pkgs = nixpkgsFor.${system};
+ };
+ _module.args.nixpkgs = nixpkgs;
+ };
+
in {
# A Nixpkgs overlay that overrides the 'nix' and
@@ -475,49 +487,22 @@
};
# System tests.
- tests.remoteBuilds = import ./tests/nixos/remote-builds.nix {
- system = "x86_64-linux";
- inherit nixpkgs;
- overlay = self.overlays.default;
- };
+ tests.remoteBuilds = runNixOSTestFor "x86_64-linux" ./tests/nixos/remote-builds.nix;
- tests.nix-copy-closure = import ./tests/nixos/nix-copy-closure.nix {
- system = "x86_64-linux";
- inherit nixpkgs;
- overlay = self.overlays.default;
- };
+ tests.nix-copy-closure = runNixOSTestFor "x86_64-linux" ./tests/nixos/nix-copy-closure.nix;
- tests.nssPreload = (import ./tests/nixos/nss-preload.nix rec {
- system = "x86_64-linux";
- inherit nixpkgs;
- overlay = self.overlays.default;
- });
+ tests.nssPreload = runNixOSTestFor "x86_64-linux" ./tests/nixos/nss-preload.nix;
- tests.githubFlakes = (import ./tests/nixos/github-flakes.nix rec {
- system = "x86_64-linux";
- inherit nixpkgs;
- overlay = self.overlays.default;
- });
+ tests.githubFlakes = runNixOSTestFor "x86_64-linux" ./tests/nixos/github-flakes.nix;
- tests.sourcehutFlakes = (import ./tests/nixos/sourcehut-flakes.nix rec {
- system = "x86_64-linux";
- inherit nixpkgs;
- overlay = self.overlays.default;
- });
+ tests.sourcehutFlakes = runNixOSTestFor "x86_64-linux" ./tests/nixos/sourcehut-flakes.nix;
- tests.containers = (import ./tests/nixos/containers/containers.nix rec {
- system = "x86_64-linux";
- inherit nixpkgs;
- overlay = self.overlays.default;
- });
+ tests.containers = runNixOSTestFor "x86_64-linux" ./tests/nixos/containers/containers.nix;
tests.setuid = nixpkgs.lib.genAttrs
["i686-linux" "x86_64-linux"]
- (system:
- import ./tests/nixos/setuid.nix rec {
- inherit nixpkgs system;
- overlay = self.overlays.default;
- });
+ (system: runNixOSTestFor system ./tests/nixos/setuid.nix);
+
# Make sure that nix-env still produces the exact same result
# on a particular version of Nixpkgs.