From 89307728649cd96cb82fba739c014c1e78a6fc31 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 29 Mar 2024 13:19:36 +0100 Subject: [PATCH] Add regression test for #10331, #10267 --- tests/functional/chroot-store.sh | 41 +++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/tests/functional/chroot-store.sh b/tests/functional/chroot-store.sh index f7c8eb3f1..9e589d04b 100644 --- a/tests/functional/chroot-store.sh +++ b/tests/functional/chroot-store.sh @@ -1,22 +1,45 @@ source common.sh -cd $TEST_ROOT +echo example > $TEST_ROOT/example.txt +mkdir -p $TEST_ROOT/x -echo example > example.txt -mkdir -p ./x +export NIX_STORE_DIR=/nix2/store -NIX_STORE_DIR=$TEST_ROOT/x +CORRECT_PATH=$(cd $TEST_ROOT && nix-store --store ./x --add example.txt) -CORRECT_PATH=$(nix-store --store ./x --add example.txt) +[[ $CORRECT_PATH =~ ^/nix2/store/.*-example.txt$ ]] -PATH1=$(nix path-info --store ./x $CORRECT_PATH) +PATH1=$(cd $TEST_ROOT && nix path-info --store ./x $CORRECT_PATH) [ $CORRECT_PATH == $PATH1 ] -PATH2=$(nix path-info --store "$PWD/x" $CORRECT_PATH) +PATH2=$(nix path-info --store "$TEST_ROOT/x" $CORRECT_PATH) [ $CORRECT_PATH == $PATH2 ] -PATH3=$(nix path-info --store "local?root=$PWD/x" $CORRECT_PATH) +PATH3=$(nix path-info --store "local?root=$TEST_ROOT/x" $CORRECT_PATH) [ $CORRECT_PATH == $PATH3 ] # Ensure store info trusted works with local store -nix --store ./x store info --json | jq -e '.trusted' +nix --store $TEST_ROOT/x store info --json | jq -e '.trusted' + +# Test building in a chroot store. +if canUseSandbox; then + + flakeDir=$TEST_ROOT/flake + mkdir -p $flakeDir + + cat > $flakeDir/flake.nix <