nt/flake/nix-unit.nix

49 lines
1 KiB
Nix
Raw Permalink Normal View History

2026-01-27 17:50:53 +10:00
{
this,
flake,
deps,
...
}: let
inherit
2026-01-28 08:49:21 +10:00
(builtins)
concatStringsSep
2026-01-27 17:50:53 +10:00
;
inherit
(this.util)
forAllSystems
;
2026-01-28 08:49:21 +10:00
inherit
(deps)
nixpkgs
nix-unit
;
in let
enable-experimental = concatStringsSep " " [
"flakes"
"nix-command"
"pipe-operators"
];
2026-01-27 17:50:53 +10:00
in {
2026-01-28 08:49:21 +10:00
# XXX: TODO: assert false || throw "TEST: type of flake is \"${builtins.typeOf flake}\""
checks = forAllSystems (
system: pkgs: {
default =
pkgs.runCommand "tests"
{
nativeBuildInputs = [nix-unit.packages.${system}.default];
}
''
export HOME="$(realpath .)"
# The nix derivation must be able to find all used inputs in the nix-store because it cannot download it during buildTime.
nix-unit --eval-store "$HOME" \
--extra-experimental-features "${enable-experimental}" \
--override-input nixpkgs ${nixpkgs} \
--flake ${flake}\#tests
touch $out
'';
}
);
2026-01-27 17:50:53 +10:00
}