Skip to content

Commit 3c8d22a

Browse files
author
Pacman99
committed
flake/tests: improve multi arch support for flake checks
1 parent aec7c92 commit 3c8d22a

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

flake.nix

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,21 @@
6262
defaultTemplate = self.templates.flk;
6363

6464
deploy.nodes = os.mkNodes deploy self.nixosConfigurations;
65-
66-
checks =
67-
let
68-
tests = import ./tests { inherit self pkgs; };
69-
deployChecks = builtins.mapAttrs
70-
(system: deployLib: deployLib.deployChecks self.deploy)
71-
deploy.lib;
72-
in
73-
nixos.lib.recursiveUpdate tests deployChecks;
7465
};
7566

7667
systemOutputs = utils.lib.eachDefaultSystem (system:
7768
let pkgs = multiPkgs.${system}; in
7869
{
70+
checks =
71+
let
72+
tests = nixos.lib.optionalAttrs (system == "x86_64-linux")
73+
(import ./tests { inherit self pkgs; });
74+
deployHosts = nixos.lib.filterAttrs
75+
(n: _: self.nixosConfigurations.${n}.config.nixpkgs.system == system) self.deploy.nodes;
76+
deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; };
77+
in
78+
nixos.lib.recursiveUpdate tests deployChecks;
79+
7980
packages = utils.lib.flattenTreeSystem system
8081
(os.mkPackages { inherit pkgs; });
8182

tests/default.nix

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,45 +59,44 @@ let
5959
nixosTesting.makeTest calledTest;
6060
in
6161
{
62-
x86_64-linux = {
63-
profilesTest = mkTest {
64-
name = "profiles";
62+
profilesTest = mkTest {
63+
name = "profiles";
6564

66-
machine = { suites, ... }: {
67-
imports = suites.allProfiles ++ suites.allUsers;
68-
};
69-
70-
testScript = ''
71-
machine.systemctl("is-system-running --wait")
72-
'';
65+
machine = { suites, ... }: {
66+
imports = suites.allProfiles ++ suites.allUsers;
7367
};
7468

75-
libTests = pkgs.runCommandNoCC "devos-lib-tests"
76-
{
77-
buildInputs = [
78-
pkgs.nix
79-
(
80-
let tests = import ./lib.nix { inherit self pkgs; };
81-
in
82-
if tests == [ ]
83-
then null
84-
else throw (builtins.toJSON tests)
85-
)
86-
];
87-
} ''
88-
datadir="${pkgs.nix}/share"
89-
export TEST_ROOT=$(pwd)/test-tmp
90-
export NIX_BUILD_HOOK=
91-
export NIX_CONF_DIR=$TEST_ROOT/etc
92-
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
93-
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
94-
export NIX_STATE_DIR=$TEST_ROOT/var/nix
95-
export NIX_STORE_DIR=$TEST_ROOT/store
96-
export PAGER=cat
97-
cacheDir=$TEST_ROOT/binary-cache
98-
nix-store --init
99-
100-
touch $out
69+
testScript = ''
70+
machine.systemctl("is-system-running --wait")
10171
'';
10272
};
73+
74+
libTests = pkgs.runCommandNoCC "devos-lib-tests"
75+
{
76+
buildInputs = [
77+
pkgs.nix
78+
(
79+
let tests = import ./lib.nix { inherit self pkgs; };
80+
in
81+
if tests == [ ]
82+
then null
83+
else throw (builtins.toJSON tests)
84+
)
85+
];
86+
} ''
87+
datadir="${pkgs.nix}/share"
88+
export TEST_ROOT=$(pwd)/test-tmp
89+
export NIX_BUILD_HOOK=
90+
export NIX_CONF_DIR=$TEST_ROOT/etc
91+
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
92+
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
93+
export NIX_STATE_DIR=$TEST_ROOT/var/nix
94+
export NIX_STORE_DIR=$TEST_ROOT/store
95+
export PAGER=cat
96+
cacheDir=$TEST_ROOT/binary-cache
97+
nix-store --init
98+
99+
touch $out
100+
'';
103101
}
102+

0 commit comments

Comments
 (0)