-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for NixOS#10331, NixOS#10267
- Loading branch information
Showing
1 changed file
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,47 @@ | ||
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 <<EOF | ||
{ | ||
description = "Bla bla"; | ||
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 |