2024-05-28 19:43:04 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-12-03 17:53:41 +02:00
|
|
|
source common.sh
|
|
|
|
|
2024-06-16 13:51:46 +03:00
|
|
|
TODO_NixOS
|
|
|
|
|
2021-12-03 17:53:41 +02:00
|
|
|
clearStore
|
|
|
|
|
2024-06-04 23:33:30 +03:00
|
|
|
writeSimpleFlake "$TEST_HOME"
|
|
|
|
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
|
2024-06-04 23:33:30 +03:00
|
|
|
nix build "$i" || fail "flake should be found by searching up directories"
|
2021-12-03 17:53:41 +02:00
|
|
|
done
|
|
|
|
|
2022-01-14 17:03:47 +02:00
|
|
|
for i in "${failure[@]}"; do
|
2024-06-04 23:33:30 +03:00
|
|
|
! nix build "$i" || fail "flake should not search up directories when using 'path:'"
|
2021-12-03 17:53:41 +02:00
|
|
|
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
|
2024-06-04 23:33:30 +03:00
|
|
|
! nix build "$i" || fail "flake should not search past a git repository"
|
2022-07-13 21:55:08 +03:00
|
|
|
done
|
|
|
|
rm -rf .git
|
|
|
|
popd
|
|
|
|
fi
|