Skip to content

Regression in symlink handling in 2.16 #9298

@jtojnar

Description

@jtojnar

Describe the bug

I have been creating a clean directory tree derivation by only symlinking interpolated paths of the relevant subdirectories.
Nix files in one of the subdirectories import files from different subdirectory.
But since the subdirectory paths are interpolated, each subdirectory will end up as a separate store path.

Since 2.16, the imported path appears to be resolved relative to realpath in some cases, breaking the previously working code.

I think this new behaviour is better in terms of #2109 but it is still a regression and I was asked to report it.

I bisected the regression to 94812cc

Steps To Reproduce

  1. Run the following commands:
mkdir -p 144-store/overlays
echo 'import ../lib' > 144-store/overlays/overlay.nix
mkdir -p 144-store/foo/lib
echo '"test"' > 144-store/foo/lib/default.nix
ln -s $PWD/144-store/overlays 144-store/foo/overlays
nix-instantiate --eval --strict "144-store/foo/overlays/overlay.nix"
  1. You will get
error:
       … while calling the 'import' builtin

         at /home/jtojnar/Projects/nixpkgs-hammering/144-store/overlays/overlay.nix:1:1:

            1| import ../lib
             | ^
            2|

       error: getting status of '/home/jtojnar/Projects/nixpkgs-hammering/144-store/lib': No such file or directory

Expected behavior

No error should be produced.

Unless this regression is acceptable, since this error is sensible wrt #2109.

nix-env --version output

2.18.1

Additional context

Discovered in jtojnar/nixpkgs-hammering#144

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

Projects

Status

🏁 Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions