1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-24 03:09:35 +01:00
nix/tests/flake-missing-file.sh
regnat 663187219a 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
2021-11-16 13:38:34 +01:00

39 lines
952 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"