forked from Fediversity/Fediversity
make expression tests build as a derivation
This commit is contained in:
parent
87601272ea
commit
729b4bb7c3
|
@ -19,5 +19,5 @@ jobs:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: cd website && nix-shell --command run-tests
|
- run: cd website && nix-build -A tests
|
||||||
- run: cd website && nix-build -A build
|
- run: cd website && nix-build -A build
|
||||||
|
|
|
@ -61,8 +61,32 @@ rec {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
tests = with pkgs; with lib; runCommand "run-tests" { } ''
|
inherit sources pkgs;
|
||||||
touch $out
|
tests = with pkgs; with lib;
|
||||||
${getExe nix-unit} ${./tests.nix} "$@"
|
let
|
||||||
'';
|
source = fileset.toSource {
|
||||||
|
root = ./.;
|
||||||
|
fileset = fileset.unions [
|
||||||
|
./default.nix
|
||||||
|
./tests.nix
|
||||||
|
./lib.nix
|
||||||
|
./npins
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
runCommand "run-tests"
|
||||||
|
{
|
||||||
|
buildInputs = [ pkgs.nix ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
export HOME="$(realpath .)"
|
||||||
|
# HACK: nix-unit initialises its own entire Nix, so it needs a store to operate on,
|
||||||
|
# but since we're in a derivation, we can't fetch sources, so copy Nixpkgs manually here.
|
||||||
|
# `''${sources.nixpkgs}` resolves to `<hash>-source`,
|
||||||
|
# adding it verbatim will result in <hash'>-<hash>-source, so rename it first
|
||||||
|
cp -r ${sources.nixpkgs} source
|
||||||
|
nix-store --add --store "$HOME" source
|
||||||
|
${getExe nix-unit} --gc-roots-dir "$HOME" --store "$HOME" ${source}/tests.nix "$@"
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue