1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-24 19:29:36 +01:00

Try and help if a file is missing at eval time

When evaluating a local git flake, if a file a missing at eval-time but
present in the source directory, tell the user that he probably forgot
to check it out

Fix #4507
This commit is contained in:
regnat 2021-07-07 14:29:58 +02:00
parent e1db5992ec
commit 663187219a
3 changed files with 74 additions and 15 deletions

View file

@ -0,0 +1,39 @@
source common.sh
if [[ -z $(type -p git) ]]; then
echo "Git not installed; skipping flake tests"
exit 99
fi
clearStore
rm -rf $TEST_HOME/.cache $TEST_HOME/.config
repo=$TEST_ROOT/flake
rm -rf $repo $repo.tmp
mkdir $repo
git -C $repo init
git -C $repo config user.email "foobar@example.com"
git -C $repo config user.name "Foobar"
cat > $repo/flake.nix <<EOF
{
description = "Bla bla";
outputs = inputs: rec {
packages.$system.foo = import ./simple.nix;
defaultPackage.$system = packages.$system.foo;
};
}
EOF
git -C $repo add flake.nix
git -C $repo commit -m 'Initial'
cp ./simple.nix $repo/
nix build $repo |& grep -q "Did you forget to track it in Git" || \
fail "Trying to access a non git-tracked file should suggest that it is probably the issue"
rm $repo/simple.nix
nix build $repo |& (! grep -q "Did you forget to track it in Git") || \
fail "Trying to use an absent file shouldnt suggest to git add it"