nix-super/tests/functional/chroot-store.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2020-07-17 22:50:53 +03:00
source common.sh
2024-03-29 14:19:36 +02:00
echo example > $TEST_ROOT/example.txt
mkdir -p $TEST_ROOT/x
2020-07-17 22:50:53 +03:00
2024-03-29 14:19:36 +02:00
export NIX_STORE_DIR=/nix2/store
2020-07-17 22:50:53 +03:00
2024-03-29 14:19:36 +02:00
CORRECT_PATH=$(cd $TEST_ROOT && nix-store --store ./x --add example.txt)
2020-07-17 22:50:53 +03:00
2024-03-29 14:19:36 +02:00
[[ $CORRECT_PATH =~ ^/nix2/store/.*-example.txt$ ]]
2020-07-17 22:50:53 +03:00
2024-03-29 14:19:36 +02:00
PATH1=$(cd $TEST_ROOT && nix path-info --store ./x $CORRECT_PATH)
2020-07-17 22:50:53 +03:00
[ $CORRECT_PATH == $PATH1 ]
2024-03-29 14:19:36 +02:00
PATH2=$(nix path-info --store "$TEST_ROOT/x" $CORRECT_PATH)
2020-07-17 22:50:53 +03:00
[ $CORRECT_PATH == $PATH2 ]
2024-03-29 14:19:36 +02:00
PATH3=$(nix path-info --store "local?root=$TEST_ROOT/x" $CORRECT_PATH)
2021-08-06 19:36:03 +03:00
[ $CORRECT_PATH == $PATH3 ]
# Ensure store info trusted works with local store
2024-03-29 14:19:36 +02:00
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 <<EOF
{
outputs = inputs: rec {
packages.$system.default = import ./simple.nix;
};
}
EOF
cp simple.nix shell.nix simple.builder.sh config.nix $flakeDir/
outPath=$(nix build --print-out-paths --no-link --sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' --store $TEST_ROOT/x path:$flakeDir)
[[ $outPath =~ ^/nix2/store/.*-simple$ ]]
[[ $(cat $TEST_ROOT/x/nix/store/$(basename $outPath)/hello) = 'Hello World!' ]]
fi