Skip to content

Legacy nix-shell with a path prefers shell.nix over default.nix #11699

@K900

Description

@K900

Describe the bug

~/test
❯ cat shell.nix
throw "i'm shell.nix"

~/test
❯ cat default.nix
throw "i'm default.nix"

~/test
❯ nix shell nixpkgs#nixVersions.nix_2_24 --command nix-shell . --attr hello
error:
       … while calling the 'throw' builtin
         at /home/k900/test/shell.nix:1:1:
            1| throw "i'm shell.nix"
             | ^
            2|

       error: i'm shell.nix

~/test
❯ nix shell nixpkgs#nixVersions.nix_2_18 --command nix-shell . --attr hello
error:
       … while calling the 'throw' builtin

         at /home/k900/test/default.nix:1:1:

            1| throw "i'm default.nix"
             | ^
            2|

       error: i'm default.nix

This also breaks a common pattern of nix-shell path/to/nixpkgs -A foo.

Steps To Reproduce

  1. Get a nixpkgs checkout
  2. nix-shell . -A hello
  3. See error

Expected behavior

A shell.

nix-env --version output

nix-env (Nix) 2.24.9

Additional context

2.18 is not affected, neither is Lix, may bisect later.

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions