2021-12-03 16:53:41 +01:00
|
|
|
source common.sh
|
|
|
|
|
2022-01-22 20:01:54 +01:00
|
|
|
if [[ -z $(type -p git) ]]; then
|
|
|
|
echo "Git not installed; skipping flake search tests"
|
|
|
|
exit 99
|
|
|
|
fi
|
|
|
|
|
2021-12-03 16:53:41 +01:00
|
|
|
clearStore
|
|
|
|
|
|
|
|
cp ./simple.nix ./simple.builder.sh ./config.nix $TEST_HOME
|
|
|
|
cd $TEST_HOME
|
2022-01-14 15:15:45 +01:00
|
|
|
mkdir -p foo/subdir
|
|
|
|
echo '{ outputs = _: {}; }' > foo/flake.nix
|
2021-12-03 16:53:41 +01:00
|
|
|
cat <<EOF > flake.nix
|
|
|
|
{
|
2022-01-14 15:15:45 +01:00
|
|
|
inputs.foo.url = "$PWD/foo";
|
2021-12-03 16:53:41 +01:00
|
|
|
outputs = a: {
|
2022-02-11 18:11:08 +01:00
|
|
|
packages.$system = rec {
|
|
|
|
test = import ./simple.nix;
|
|
|
|
default = test;
|
|
|
|
};
|
2021-12-03 16:53:41 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
mkdir subdir
|
2022-01-14 15:15:45 +01:00
|
|
|
pushd subdir
|
2021-12-03 16:53:41 +01:00
|
|
|
|
2022-01-14 16:03:47 +01:00
|
|
|
success=("" . .# .#test ../subdir ../subdir#test "$PWD")
|
|
|
|
failure=("path:$PWD")
|
|
|
|
|
|
|
|
for i in "${success[@]}"; do
|
2021-12-03 16:53:41 +01:00
|
|
|
nix build $i || fail "flake should be found by searching up directories"
|
|
|
|
done
|
|
|
|
|
2022-01-14 16:03:47 +01:00
|
|
|
for i in "${failure[@]}"; do
|
2021-12-03 16:53:41 +01:00
|
|
|
! nix build $i || fail "flake should not search up directories when using 'path:'"
|
|
|
|
done
|
2022-01-14 15:15:45 +01:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
nix build --override-input foo . || fail "flake should search up directories when not an installable"
|
|
|
|
|
|
|
|
sed "s,$PWD/foo,$PWD/foo/subdir,g" -i flake.nix
|
|
|
|
! nix build || fail "flake should not search upwards when part of inputs"
|
2022-01-14 16:03:47 +01:00
|
|
|
|
|
|
|
pushd subdir
|
|
|
|
git init
|
|
|
|
for i in "${success[@]}" "${failure[@]}"; do
|
|
|
|
! nix build $i || fail "flake should not search past a git repository"
|
|
|
|
done
|
|
|
|
rm -rf .git
|
|
|
|
popd
|