Move flake-searching.sh and make it less dependent on git

This commit is contained in:
Eelco Dolstra 2022-07-13 20:55:08 +02:00
parent 6ba45f81a8
commit 752158a8ef
2 changed files with 12 additions and 14 deletions

View file

@ -1,15 +1,11 @@
source common.sh source common.sh
if [[ -z $(type -p git) ]]; then
echo "Git not installed; skipping flake search tests"
exit 99
fi
clearStore clearStore
cp ./simple.nix ./simple.builder.sh ./config.nix $TEST_HOME writeSimpleFlake $TEST_HOME
cd $TEST_HOME cd $TEST_HOME
mkdir -p foo/subdir mkdir -p foo/subdir
echo '{ outputs = _: {}; }' > foo/flake.nix echo '{ outputs = _: {}; }' > foo/flake.nix
cat <<EOF > flake.nix cat <<EOF > flake.nix
{ {
@ -43,10 +39,12 @@ nix build --override-input foo . || fail "flake should search up directories whe
sed "s,$PWD/foo,$PWD/foo/subdir,g" -i flake.nix sed "s,$PWD/foo,$PWD/foo/subdir,g" -i flake.nix
! nix build || fail "flake should not search upwards when part of inputs" ! nix build || fail "flake should not search upwards when part of inputs"
pushd subdir if [[ -n $(type -p git) ]]; then
git init pushd subdir
for i in "${success[@]}" "${failure[@]}"; do git init
for i in "${success[@]}" "${failure[@]}"; do
! nix build $i || fail "flake should not search past a git repository" ! nix build $i || fail "flake should not search past a git repository"
done done
rm -rf .git rm -rf .git
popd popd
fi

View file

@ -49,7 +49,7 @@ nix_tests = \
secure-drv-outputs.sh \ secure-drv-outputs.sh \
restricted.sh \ restricted.sh \
fetchGitSubmodules.sh \ fetchGitSubmodules.sh \
flake-searching.sh \ flakes/search-root.sh \
ca/duplicate-realisation-in-closure.sh \ ca/duplicate-realisation-in-closure.sh \
readfile-context.sh \ readfile-context.sh \
nix-channel.sh \ nix-channel.sh \