nix/tests/functional/flakes/eval-cache.sh

40 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2024-05-24 14:16:38 +00:00
source ./common.sh
requireGit
flake1Dir="$TEST_ROOT/eval-cache-flake"
createGitRepo "$flake1Dir" ""
2024-06-29 11:19:04 +00:00
cp ../simple.nix ../simple.builder.sh ../config.nix "$flake1Dir/"
git -C "$flake1Dir" add simple.nix simple.builder.sh config.nix
git -C "$flake1Dir" commit -m "config.nix"
2024-05-24 14:16:38 +00:00
cat >"$flake1Dir/flake.nix" <<EOF
{
description = "Fnord";
2024-06-29 11:19:04 +00:00
outputs = { self }: let inherit (import ./config.nix) mkDerivation; in {
2024-05-24 14:16:38 +00:00
foo.bar = throw "breaks";
2024-06-29 11:19:04 +00:00
drv = mkDerivation {
name = "build";
buildCommand = ''
echo true > \$out
'';
};
ifd = assert (import self.drv); self.drv;
2024-05-24 14:16:38 +00:00
};
}
EOF
git -C "$flake1Dir" add flake.nix
git -C "$flake1Dir" commit -m "Init"
expect 1 nix build "$flake1Dir#foo.bar" 2>&1 | grepQuiet 'error: breaks'
expect 1 nix build "$flake1Dir#foo.bar" 2>&1 | grepQuiet 'error: breaks'
2024-06-29 11:19:04 +00:00
# Conditional error should not be cached
expect 1 nix build "$flake1Dir#ifd" --option allow-import-from-derivation false 2>&1 \
| grepQuiet 'error: cannot build .* during evaluation because the option '\''allow-import-from-derivation'\'' is disabled'
nix build --no-link "$flake1Dir#ifd"