nix-super/doc/manual/rl-next/nix-shell-looks-for-shell-nix.md
Robert Hensing cfe3ee3de8
nix-shell: look up shell.nix when argument is a directory (#11057)
* Refactor: rename runEnv -> isNixShell

* Refactor: rename left -> remainingArgs

* nix-build.cc: Refactor: extract baseDir variable

* nix-build.cc: Refactor: extract sourcePath, resolvedPath variables

* nix-shell: Look for shell.nix when directory is specified

* Add legacy setting: nix-shell-always-looks-for-shell-nix

* rl-next: Add note about shell.nix lookups

* tests/functional/shell.nix: Implement runHook for dummy stdenv
2024-07-08 14:36:36 +02:00

821 B

synopsis significance issues prs
`nix-shell <directory>` looks for `shell.nix` significant
496
2279
4529
5431
11053
11057

nix-shell $x now looks for $x/shell.nix when $x resolves to a directory.

Although this might be seen as a breaking change, its primarily interactive usage makes it a minor issue. This adjustment addresses a commonly reported problem.

This also applies to nix-shell shebang scripts. Consider the following example:

#!/usr/bin/env nix-shell
#!nix-shell -i bash

This will now load shell.nix from the script's directory, if it exists; default.nix otherwise.

The old behavior can be opted into by setting the option nix-shell-always-looks-for-shell-nix to false.