-
Notifications
You must be signed in to change notification settings - Fork 0
/
checks.nix
45 lines (42 loc) · 1.21 KB
/
checks.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ inputs, ... }:
let
testModule =
{ pkgs, config, ... }:
{
imports = [
inputs.self.nixosModules.host
];
# silence warning
system.stateVersion = config.system.nixos.release;
# debugging in interactive driver
environment.systemPackages = [ pkgs.tcpdump ];
# use this test module in the containers recursively
nixos-nspawn = {
imports = [
testModule
];
};
};
in
{
perSystem =
{ pkgs, lib, ... }:
let
checkFiles = lib.mapAttrsToList (fn: _: fn) (
lib.filterAttrs (fn: type: type == "regular" && lib.hasSuffix ".nix" fn) (builtins.readDir ./checks)
);
callCheck = fn: import ./checks/${fn} { inherit pkgs lib inputs; };
checkExprs = lib.listToAttrs (
map (fn: lib.nameValuePair (lib.removeSuffix ".nix" fn) (callCheck fn)) checkFiles
);
nixosTest =
(import "${inputs.nixpkgs}/nixos/lib/testing-python.nix" {
inherit (pkgs.stdenv.hostPlatform) system;
inherit pkgs;
extraConfigurations = [ testModule ];
}).simpleTest;
in
{
checks = lib.mapAttrs (name: expr: nixosTest (expr // { inherit name; })) checkExprs;
};
}