Skip to content

imports don't resolve symlinks absolutely, leading to unexpected behaviour #2109

@infinisil

Description

@infinisil

Have a look at the following directory structure:

.
├── 1
│   ├── content.nix                       content: "In 1"
│   └── default.nix -> ../2/default.nix
└── 2
    ├── content.nix                       content: "In 2"
    └── default.nix                       content: import ./content.nix

Now this is what happens with evaluation:

$ nix-instantiate --eval 1
"In 1"
$ nix-instantiate --eval 2
"In 2"

However what I expect to happen is

$ nix-instantiate --eval 1
"In 2"
$ nix-instantiate --eval 2
"In 2"

because the symlink should have influenced all imports as well.

This can lead to unexpected behaviour. A good example of this is if I were to have a directory like this (with /path/to/nixpkgs being a nixpkgs checkout):

.
└── nixos -> /path/to/nixpkgs/nixos

Then trying to use this folder will fail:

$ nix-instantiate nixos/release-combined.nix -A tested
error: opening file '/home/infinisil/Test/nixsym/default.nix': No such file or directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions