Nix Language: Tips & Tricks: Difference between revisions
imported>Mateusauler m Update the label of the link to "Overview of the Nix Language" |
mention using :edit as surrogate jump to definition Tag: 2017 source edit |
||
Line 17: | Line 17: | ||
</pre> | </pre> | ||
This doesn't work for non-functions or builtin functions, which show <code>«primop»</code>. It will always find the actual lambda, not an attribute that reexports a partial application, for example. | This doesn't work for non-functions or builtin functions, which show <code>«primop»</code>. It will always find the actual lambda, not an attribute that reexports a partial application, for example. | ||
Also in the REPL, you may use the <code>:edit</code> command (or its abbreviation <code>:e</code>) on an expression to open your editor (detected from the <code>$EDITOR</code> environment variable) at the location where an attribute was defined. | |||
<syntaxhighlight lang="bash"> | |||
$ nix repl --expr '{ pkgs = import <nixpkgs> { }; }' | |||
nix-repl> :e pkgs.lib.strings.makeBinPath | |||
</syntaxhighlight> | |||
The position information is not always perfectly accurate, but the above sequence of commands ''should'' open your editor to somewhere close to https://github.com/NixOS/nixpkgs/blob/b6ed1c5ee1470faf835024587c25fafb03693cbe/lib/strings.nix#L228. | |||
== Convert a string to an (<code>import</code>-able) path == | == Convert a string to an (<code>import</code>-able) path == |