dream2nix/modules/flake-parts/checks.nix-unit.nix
DavHau d8e4b477e3 refactor: move dev related things to /dev-flake
The goal is to reduce the flake inputs visible to the user
Still, the top-level flake re-exposes the outputs of the dev-flake, but
without exposing its inputs. This means a devShell is still available in
the top-level, for example.

This also removes the /modules/flake.nix. Its original purpose was
separating the modules inputs from the development inputs, but this is
now done the opposite way around by moving the dev inputs to
/dev-flake/flake.nix.
2023-11-05 03:42:18 +00:00

38 lines
1.1 KiB
Nix

# evaluate packages from `/**/modules/drvs` and export them via `flake.packages`
{self, ...}: {
perSystem = {
pkgs,
inputs',
lib,
system,
...
}: let
dream2nixFlake = import ../../. {};
inputs = lib.mapAttrs (name: input: "${input.outPath}") dream2nixFlake.inputs;
inputsFile = builtins.toFile "inputs.json" (builtins.toJSON inputs);
in
lib.optionalAttrs (system == "x86_64-linux") {
# map all modules in /examples to a package output in the flake.
checks.nix-unit =
pkgs.runCommand "nix-unit-tests" {
nativeBuildInputs = [
pkgs.nix
];
} ''
export NIX_PATH=nixpkgs=${pkgs.path}
export HOME=$(realpath .)
for test in ${../..}/tests/nix-unit/*; do
if [ -f "$test" ]; then
continue
fi
echo -e "Executing tests from file $test"
${inputs'.nix-unit.packages.nix-unit}/bin/nix-unit \
"$test" \
--eval-store $(realpath .) \
--arg inputs 'builtins.fromJSON (builtins.readFile ${inputsFile})'
done
touch $out
'';
};
}