2021-12-03 15:53:41 +00:00
|
|
|
source common.sh
|
|
|
|
|
|
|
|
clearStore
|
|
|
|
|
2022-07-13 18:55:08 +00:00
|
|
|
writeSimpleFlake $TEST_HOME
|
2021-12-03 15:53:41 +00:00
|
|
|
cd $TEST_HOME
|
2022-01-14 14:15:45 +00:00
|
|
|
mkdir -p foo/subdir
|
2022-07-13 18:55:08 +00:00
|
|
|
|
2022-01-14 14:15:45 +00:00
|
|
|
echo '{ outputs = _: {}; }' > foo/flake.nix
|
2021-12-03 15:53:41 +00:00
|
|
|
cat <<EOF > flake.nix
|
|
|
|
{
|
2022-01-14 14:15:45 +00:00
|
|
|
inputs.foo.url = "$PWD/foo";
|
2021-12-03 15:53:41 +00:00
|
|
|
outputs = a: {
|
2022-02-11 17:11:08 +00:00
|
|
|
packages.$system = rec {
|
|
|
|
test = import ./simple.nix;
|
|
|
|
default = test;
|
|
|
|
};
|
2021-12-03 15:53:41 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
mkdir subdir
|
2022-01-14 14:15:45 +00:00
|
|
|
pushd subdir
|
2021-12-03 15:53:41 +00:00
|
|
|
|
2022-01-14 15:03:47 +00:00
|
|
|
success=("" . .# .#test ../subdir ../subdir#test "$PWD")
|
|
|
|
failure=("path:$PWD")
|
|
|
|
|
|
|
|
for i in "${success[@]}"; do
|
2021-12-03 15:53:41 +00:00
|
|
|
nix build $i || fail "flake should be found by searching up directories"
|
|
|
|
done
|
|
|
|
|
2022-01-14 15:03:47 +00:00
|
|
|
for i in "${failure[@]}"; do
|
2021-12-03 15:53:41 +00:00
|
|
|
! nix build $i || fail "flake should not search up directories when using 'path:'"
|
|
|
|
done
|
2022-01-14 14:15:45 +00: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 15:03:47 +00:00
|
|
|
|
2022-07-13 18:55:08 +00:00
|
|
|
if [[ -n $(type -p git) ]]; then
|
|
|
|
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
|
|
|
|
fi
|