Home Explore Blog CI



nix

5th chunk of `doc/manual/source/release-notes/rl-2.24.md`
c8d9d231db5a0dd0aa53a4a332ddce280c2e669c9a92a3660000000100000ab0
  <!-- unfortunately no link target for the specific syntax -->
  Relative [path](@docroot@/language/types.md#type-path) literals in `nix-shell` shebang scripts' options are now resolved relative to the [script's location](@docroot@/glossary.md?highlight=base%20directory#gloss-base-directory).
  Previously they were resolved relative to the current working directory.

  For example, consider the following script in `~/myproject/say-hi`:

  ```shell
  #!/usr/bin/env nix-shell
  #!nix-shell --expr 'import ./shell.nix'
  #!nix-shell --arg toolset './greeting-tools.nix'
  #!nix-shell -i bash
  hello
  ```

  Older versions of `nix-shell` would resolve `shell.nix` relative to the current working directory, such as the user's home directory in this example:

  ```console
  [hostname:~]$ ./myproject/say-hi
  error:
         … while calling the 'import' builtin
           at «string»:1:2:
              1| (import ./shell.nix)
               |  ^

         error: path '/home/user/shell.nix' does not exist
  ```

  Since this release, `nix-shell` resolves `shell.nix` relative to the script's location, and `~/myproject/shell.nix` is used.

  ```console
  $ ./myproject/say-hi
  Hello, world!
  ```

  **Opt-out**

  This is technically a breaking change, so we have added an option so you can adapt independently of your Nix update.
  The old behavior can be opted into by setting the option [`nix-shell-shebang-arguments-relative-to-script`](@docroot@/command-ref/conf-file.md#conf-nix-shell-shebang-arguments-relative-to-script) to `false`.
  This option will be removed in a future release.

  Author: [**Robert Hensing (@roberth)**](https://github.com/roberth)

- Improve handling of tarballs that don't consist of a single top-level directory [#11195](https://github.com/NixOS/nix/pull/11195)

  In previous Nix releases, the tarball fetcher (used by `builtins.fetchTarball`) erroneously merged top-level directories into a single directory, and silently discarded top-level files that are not directories. This is no longer the case. The new behaviour is that *only* if the tarball consists of a single directory, the top-level path component of the files in the tarball is removed (similar to `tar`'s `--strip-components=1`).

  Author: [**Eelco Dolstra (@edolstra)**](https://github.com/edolstra)

- Setting to warn about large paths [#10778](https://github.com/NixOS/nix/pull/10778)

  Nix can now warn when evaluation of a Nix expression causes a large
  path to be copied to the Nix store. The threshold for this warning can
  be configured using the `warn-large-path-threshold` setting,
  e.g. `--warn-large-path-threshold 100M`.


# Contributors

This release was made possible by the following 43 contributors:

Title: Nix Release 2.24.0: Nix-Shell Shebang Path Resolution, Tarball Handling, and Large Path Warning
Summary
This section details improvements in Nix release 2.24.0, including resolving relative paths in `nix-shell` shebang scripts relative to the script's location (with an opt-out option), improved handling of tarballs without a single top-level directory, and a setting to warn about large paths being copied to the Nix store.