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:
commit
d2a07a96ba
8 changed files with 108 additions and 72 deletions
|
@ -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" ];
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue