1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 19:23:54 +02:00

Merge pull request #10467 from edolstra/nix-shell-symlink

nix shell: Handle output paths that are symlinks
This commit is contained in:
Théophane Hufschmitt 2024-04-16 12:31:14 +02:00 committed by GitHub
commit d2a07a96ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 108 additions and 72 deletions

View file

@ -1,6 +1,6 @@
with import ./config.nix;
{
rec {
hello = mkDerivation {
name = "hello";
outputs = [ "out" "dev" ];
@ -24,6 +24,22 @@ with import ./config.nix;
'';
};
hello-symlink = mkDerivation {
name = "hello-symlink";
buildCommand =
''
ln -s ${hello} $out
'';
};
forbidden-symlink = mkDerivation {
name = "forbidden-symlink";
buildCommand =
''
ln -s /tmp/foo/bar $out
'';
};
salve-mundi = mkDerivation {
name = "salve-mundi";
outputs = [ "out" ];

View file

@ -10,6 +10,11 @@ nix shell -f shell-hello.nix hello -c hello NixOS | grep 'Hello NixOS'
nix shell -f shell-hello.nix hello^dev -c hello2 | grep 'Hello2'
nix shell -f shell-hello.nix 'hello^*' -c hello2 | grep 'Hello2'
# Test output paths that are a symlink.
nix shell -f shell-hello.nix hello-symlink -c hello | grep 'Hello World'
# Test that symlinks outside of the store don't work.
expect 1 nix shell -f shell-hello.nix forbidden-symlink -c hello 2>&1 | grepQuiet "is not in the Nix store"
if isDaemonNewer "2.20.0pre20231220"; then
# Test that command line attribute ordering is reflected in the PATH