1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Add test that mkdir $HOME fails with permission error

This commit is contained in:
Noam Yorav-Raphael 2024-08-30 18:27:19 +03:00
parent b95af5c672
commit a1337f5a0c
2 changed files with 13 additions and 0 deletions

View file

@ -152,6 +152,11 @@ nix build --impure -f multiple-outputs.nix --json e --no-link \
(.outputs | keys == ["a_a", "b"])) (.outputs | keys == ["a_a", "b"]))
' '
# Make sure that `mkdir $HOME fails with a "Permission denied" error`
out="$(nix build -f mkdir-home-failing.nix -L 2>&1)" && status=0 || status=$?
test "$status" = 1
<<<"$out" grepQuiet -E "Permission denied"
# Make sure that `--stdin` works and does not apply any defaults # Make sure that `--stdin` works and does not apply any defaults
printf "" | nix build --no-link --stdin --json | jq --exit-status '. == []' printf "" | nix build --no-link --stdin --json | jq --exit-status '. == []'
printf "%s\n" "$drv^*" | nix build --no-link --stdin --json | jq --exit-status '.[0]|has("drvPath")' printf "%s\n" "$drv^*" | nix build --no-link --stdin --json | jq --exit-status '.[0]|has("drvPath")'

View file

@ -0,0 +1,8 @@
with import ./config.nix;
mkDerivation {
name = "mkdir-home-no-permission";
builder = builtins.toFile "builder.sh"
''
mkdir $HOME
'';
}