NixOS / NixOS/nix

`nix-shell` regression for `shell.nix` symlinks to other directories

Open
#11,630 2 comments 0 reactions 1 assignee View on GitHub

@roberth is already working on this.

Since Oct 31, 2024.

bug
Dominant language
C++
Stars
17.7k
Forks
2k
Avg merge
1d 19h
Merged PRs (30d)
76

Description

Describe the bug

I've got a project set up where I have a top-level shell.nix symlink, which points to ./subdirectory/shell.nix.
When I upgraded to the most recent version of nix (2.24.7) suddenly all expressions in ./subdirectory/shell.nix with relative files (such as import ./foo.nix) try to look for these files not in subdirectory but in the top-level directory instead, which then results in a error: path '/home/user/toplevel/foo.nix' does not exist.

Minimal example

I uploaded a reproducer for the issue here: https://github.com/knedlsepp/nix-11630

Additional context

I bisected the issue and the change of behavior was introduced with commit https://github.com/NixOS/nix/commit/cfe3ee3de84458a8962a6c714e602e6791666101, part of https://github.com/NixOS/nix/pull/11057.

Workaround

Using nix-shell --option nix-shell-always-looks-for-shell-nix false restores the previous behavior. (However the option's name doesn't suggest that this is intended to have an influence)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.