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