mirror of
https://github.com/NixOS/nix.git
synced 2025-11-10 04:26:01 +01:00
Adding paths to the store can be slow due to I/O overhead, but especially when going through the daemon because of the round-trip latency of every wopAddToStore call. So we now do the addToStore() calls asynchronously from a separate thread from the evaluator. This slightly speeds up the local store, and makes going through the daemon almost as fast as a local store.
58 lines
1.8 KiB
Bash
Executable file
58 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
source ./common.sh
|
|
|
|
requireGit
|
|
|
|
flake1Dir="$TEST_ROOT/eval-cache-flake"
|
|
|
|
createGitRepo "$flake1Dir" ""
|
|
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"
|
|
|
|
cat >"$flake1Dir/flake.nix" <<EOF
|
|
{
|
|
description = "Fnord";
|
|
outputs = { self }: let inherit (import ./config.nix) mkDerivation; in {
|
|
foo.bar = throw "breaks";
|
|
drv = mkDerivation {
|
|
name = "build";
|
|
buildCommand = ''
|
|
echo true > \$out
|
|
'';
|
|
};
|
|
stack-depth =
|
|
let
|
|
f = x: if x == 0 then true else f (x - 1);
|
|
in
|
|
assert (f 100); self.drv;
|
|
ifd = assert (import self.drv); self.drv;
|
|
};
|
|
}
|
|
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'
|
|
|
|
# Stack overflow error must not be cached
|
|
expect 1 nix build --max-call-depth 50 "$flake1Dir#stack-depth" 2>&1 \
|
|
| grepQuiet 'error: stack overflow; max-call-depth exceeded'
|
|
# If the SO is cached, the following invocation will produce a cached failure; we expect it to succeed
|
|
nix build --no-link "$flake1Dir#stack-depth"
|
|
|
|
# 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"
|
|
|
|
# Test that a store derivation is recreated when it has been deleted
|
|
# but the corresponding attribute is still cached.
|
|
if ! isTestOnNixOS; then
|
|
nix build "$flake1Dir#drv"
|
|
clearStore
|
|
nix build "$flake1Dir#drv"
|
|
fi
|