mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
nix flake check: Skip substitutable derivations
Since `nix flake check` doesn't produce a `result` symlink, it doesn't actually need to build/substitute derivations that are already known to have succeeded, i.e. that are substitutable. This can speed up CI jobs in cases where the derivations have already been built by other jobs. For instance, a command like nix flake check github:NixOS/hydra/aa62c7f7db31753f0cde690f8654dd1907fc0ce2 should no longer build anything because the outputs are already in cache.nixos.org. Based-on: https://github.com/DeterminateSystems/nix-src/pull/134 Based-on: https://gerrit.lix.systems/c/lix/+/3841 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
1907a3300f
commit
ecdda5798c
3 changed files with 55 additions and 2 deletions
|
|
@ -167,3 +167,23 @@ EOF
|
|||
if !isTestOnNixOS && $NIX_REMOTE != daemon; then
|
||||
expectStderr 100 nix flake check "$flakeDir" | grepQuiet 'builder failed with exit code 1'
|
||||
fi
|
||||
|
||||
# Ensure non-substitutable (read: usually failed) checks are actually run
|
||||
# https://github.com/NixOS/nix/pull/13574
|
||||
cp "$config_nix" $flakeDir/
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: with import ./config.nix; {
|
||||
checks.${system}.expectedToFail = derivation {
|
||||
name = "expected-to-fail";
|
||||
inherit system;
|
||||
builder = "not-a-real-file";
|
||||
};
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
# NOTE: Regex pattern is used for compatibility with older daemon versions
|
||||
# We also can't expect a specific status code. Earlier daemons return 1, but as of 2.31, we return 100
|
||||
checkRes=$(nix flake check $flakeDir 2>&1 && fail "nix flake check should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet -E "builder( for .*)? failed with exit code 1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue