Home Explore Blog CI



nix

4th chunk of `doc/manual/source/release-notes/rl-2.20.md`
c7d9cd6e7ba1d63b1a460e3c5a7aeb99b5d4700db979f5b30000000100000c05
         … while evaluating an attribute name

         error: value is a set while a string was expected
  ```

  Now, the error message displays where the problematic value was found:

  ```
  error:
         … while evaluating an attribute name

           at bad.nix:4:11:

              3|   key = {};
              4| in attr.${key}
               |           ^
              5|

         error: expected a string but found a set
  ```

- Some stack overflow segfaults are fixed [#9616](https://github.com/NixOS/nix/issues/9616) [#9617](https://github.com/NixOS/nix/pull/9617)

  The number of nested function calls has been restricted, to detect and report
  infinite function call recursions. The default maximum call depth is 10,000 and
  can be set with [the `max-call-depth`
  option](@docroot@/command-ref/conf-file.md#conf-max-call-depth).

  This replaces the `stack overflow (possible infinite recursion)` message.

- Better error reporting for `with` expressions [#9658](https://github.com/NixOS/nix/pull/9658)

  `with` expressions using non-attrset values to resolve variables are now reported with proper positions, e.g.

  ```
  nix-repl> with 1; a
  error:
         … while evaluating the first subexpression of a with expression
           at «string»:1:1:
              1| with 1; a
               | ^

         error: expected a set but found an integer
  ```

- Functions are printed with more detail [#7145](https://github.com/NixOS/nix/issues/7145) [#9606](https://github.com/NixOS/nix/pull/9606)

  `nix repl`, `nix eval`, `builtins.trace`, and most other places values are
  printed will now include function names and source location information:

  ```
  $ nix repl nixpkgs
  nix-repl> builtins.map
  «primop map»

  nix-repl> builtins.map lib.id
  «partially applied primop map»

  nix-repl> builtins.trace lib.id "my-value"
  trace: «lambda id @ /nix/store/8rrzq23h2zq7sv5l2vhw44kls5w0f654-source/lib/trivial.nix:26:5»
  "my-value"
  ```

- Flake operations like `nix develop` will no longer fail when run in a Git
  repository where the `flake.lock` file is `.gitignore`d
  [#8854](https://github.com/NixOS/nix/issues/8854)
  [#9324](https://github.com/NixOS/nix/pull/9324)

- Nix commands will now respect Ctrl-C
  [#7145](https://github.com/NixOS/nix/issues/7145)
  [#6995](https://github.com/NixOS/nix/pull/6995)
  [#9687](https://github.com/NixOS/nix/pull/9687)

  Previously, many Nix commands would hang indefinitely if Ctrl-C was pressed
  while performing various operations (including `nix develop`, `nix flake
  update`, and so on). With several fixes to Nix's signal handlers, Nix
  commands will now exit quickly after Ctrl-C is pressed.

- `nix copy` to a `ssh-ng` store now needs `--substitute-on-destination` (a.k.a. `-s`)
  in order to substitute paths on the remote store instead of copying them.
  The behavior is consistent with `nix copy` to a different kind of remote store.
  Previously this behavior was controlled by the
  `builders-use-substitutes` setting and `--substitute-on-destination` was ignored.

Title: Nix 2.20.0 Error Reporting and Usability Improvements
Summary
Nix 2.20.0 brings improvements to error reporting, making it easier to debug Nix expressions. It includes better source location information in errors, fixes for stack overflow issues with function call depth limits, and improved error messages for `with` expressions. Functions now print with more detail, including names and source locations, in `nix repl`, `nix eval`, and `builtins.trace`. Flake operations now work correctly in Git repositories with `.gitignore`d `flake.lock` files. Nix commands now respond to Ctrl-C interrupts, and `nix copy` to `ssh-ng` stores requires `--substitute-on-destination` for remote substitutions.