:doc builtins.derivation errors out since at least 2.93.3 #1191

Open
opened 2026-04-23 13:50:08 +00:00 by blokyk · 1 comment
Member

Describe the bug

Typing :doc builtins.derivation in the repl returns the following error, instead of showing the corresponding documentation:

nix-repl> :doc builtins.derivation
error: lambda '«internal»:1:148' doesn't have a determinable source file

Since 2.93.3 is the oldest release still in nixpkgs, so that's as far back as i can test this offhand, but the bug might be older. For reference, CppNix (tested on 2.31.3, the version in current nixpkgs) displays the documentation correctly.

Steps To Reproduce

  1. Open REPL
  2. Type :doc builtins.derivation
  3. See error
  4. Frown

Expected behavior

It displays the documentation associated with builtins.derivation.

nix --version output

This happens on 2.95.1, 2.94.1, and 2.93.3, at least on an x86_64 ubuntu.

nix (Lix, like Nix) 2.95.1
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/courvoie/.config/nix/nix.conf:/etc/xdg/xdg-ubuntu-xorg/nix/nix.conf:/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/slkbw0cg08jhfsax6kc0bf6rvw7rkl26-lix-2.95.1/share

Additional context

One interesting implementation detail that even CppNix leaks1 is that builtins.derivation is actually defined at <nix/derivation-internal.nix>, which is lix/libexpr/primops/derivation.nix. Weirdly enough, other builtins defined with nix (such as fetchurl) don't leak that with CppNix, and work correctly with Lix, so it seems there is something really special about derivation.nix. If somefew more familiar with the implementation could pitch in or give some hint as to what might be the culprit, I'm very curious; I haven't looked at the code path for :doc builtins.* in a while.


  1. Specifically, the output of the :doc builtins.derivation command starts with Function defined at <nix/derivation-internal.nix>:30:1 ↩︎

## Describe the bug Typing `:doc builtins.derivation` in the repl returns the following error, instead of showing the corresponding documentation: ``` nix-repl> :doc builtins.derivation error: lambda '«internal»:1:148' doesn't have a determinable source file ``` Since 2.93.3 is the oldest release still in nixpkgs, so that's as far back as i can test this offhand, but the bug might be older. For reference, CppNix (tested on 2.31.3, the version in current nixpkgs) displays the documentation correctly. ## Steps To Reproduce 1. Open REPL 2. Type `:doc builtins.derivation` 3. See error 4. Frown ## Expected behavior It displays the documentation associated with `builtins.derivation`. ## `nix --version` output This happens on 2.95.1, 2.94.1, and 2.93.3, at least on an x86_64 ubuntu. ``` nix (Lix, like Nix) 2.95.1 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/courvoie/.config/nix/nix.conf:/etc/xdg/xdg-ubuntu-xorg/nix/nix.conf:/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/slkbw0cg08jhfsax6kc0bf6rvw7rkl26-lix-2.95.1/share ``` ## Additional context One interesting implementation detail that even CppNix leaks[^1] is that `builtins.derivation` is actually defined at `<nix/derivation-internal.nix>`, which is [lix/libexpr/primops/derivation.nix](https://git.lix.systems/lix-project/lix/src/commit/be34bc0481c29f858f9444989851a6527c3e813c/lix/libexpr/primops/derivation.nix). Weirdly enough, other builtins defined with nix (such as `fetchurl`) don't leak that with CppNix, and work correctly with Lix, so it seems there is something _really_ special about `derivation.nix`. If somefew more familiar with the implementation could pitch in or give some hint as to what might be the culprit, I'm very curious; I haven't looked at the code path for `:doc builtins.*` in a while. [^1]: Specifically, the output of the `:doc builtins.derivation` command starts with `Function defined at <nix/derivation-internal.nix>:30:1`
Owner

builtins.fetchurl is not defined in nix code, it's a proper c++ primop. you have to import <nix/fetchurl.nix> to get the nix-defined derivation-based fetchurl. both that one and derivation do not have inspectable documentation via lixdoc because lixdoc expects sources to come only from files, not inline strings. if you define a lambda with docs inline in the repl those docs also don't show up for the same reason.

this should be easy enough to fix in the repl hookup of lixdoc, though we will also want to extend the Hidden source type to also lug around a string_view of the source instead of moving the builtins to use String sources (otherwise they'll show up in backtraces, which is usually not helpful)

`builtins.fetchurl` is not defined in nix code, it's a proper c++ primop. you have to `import <nix/fetchurl.nix>` to get the nix-defined derivation-based fetchurl. both that one and `derivation` do not have inspectable documentation via lixdoc because lixdoc expects sources to come only from *files*, not inline strings. if you define a lambda with docs inline in the repl those docs also don't show up for the same reason. this should be easy enough to fix in the repl hookup of lixdoc, though we will also want to extend the `Hidden` source type to also lug around a `string_view` of the source instead of moving the builtins to use `String` sources (otherwise they'll show up in backtraces, which is usually not helpful)
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1191
No description provided.