mirror of
https://github.com/NixOS/nix
synced 2025-06-28 17:51:15 +02:00
This way, we don't need the PathDisplaySourceAccessor source accessor hack, since error messages are produced directly by the original source accessor. In fact, we don't even need to copy the inputs to the store at all, so this gets us very close to lazy trees. We just need to know the store path so that requires hashing the entire input, which isn't lazy. But the next step will be to use a virtual store path that gets rewritten to the actual store path only when needed.
42 lines
1.1 KiB
Bash
42 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
source ./common.sh
|
|
|
|
requireGit
|
|
|
|
repo=$TEST_ROOT/repo
|
|
|
|
createGitRepo "$repo"
|
|
|
|
cat > "$repo/flake.nix" <<EOF
|
|
{
|
|
outputs = { ... }: {
|
|
x = 1;
|
|
y = assert false; 1;
|
|
z = builtins.readFile ./foo;
|
|
};
|
|
}
|
|
EOF
|
|
|
|
expectStderr 1 nix eval "$repo#x" | grepQuiet "error: File 'flake.nix' in the repository \"$repo\" is not tracked by Git."
|
|
|
|
git -C "$repo" add flake.nix
|
|
|
|
[[ $(nix eval "$repo#x") = 1 ]]
|
|
|
|
expectStderr 1 nix eval "$repo#y" | grepQuiet "at $repo/flake.nix:"
|
|
|
|
git -C "$repo" commit -a -m foo
|
|
|
|
expectStderr 1 nix eval "git+file://$repo?ref=master#y" | grepQuiet "at «git+file://$repo?ref=master&rev=.*»/flake.nix:"
|
|
|
|
expectStderr 1 nix eval "$repo#z" | grepQuiet "error: path '/foo' does not exist in Git repository \"$repo\""
|
|
expectStderr 1 nix eval "git+file://$repo?ref=master#z" | grepQuiet "error: '«git+file://$repo?ref=master&rev=.*»/foo' does not exist"
|
|
|
|
echo foo > "$repo/foo"
|
|
|
|
expectStderr 1 nix eval "$repo#z" | grepQuiet "error: File 'foo' in the repository \"$repo\" is not tracked by Git."
|
|
|
|
git -C "$repo" add "$repo/foo"
|
|
|
|
[[ $(nix eval --raw "$repo#z") = foo ]]
|