Home Explore Blog Models CI



nix

1st chunk of `src/nix/edit.md`
40c0b83eb32a4a50b6186a0aee5d623f32ea961cc02de40c0000000100000382
R""(

# Examples

* Open the Nix expression of the GNU Hello package:

  ```console
  # nix edit nixpkgs#hello
  ```

* Get the filename and line number used by `nix edit`:

  ```console
  # nix eval --raw nixpkgs#hello.meta.position
  /nix/store/fvafw0gvwayzdan642wrv84pzm5bgpmy-source/pkgs/applications/misc/hello/default.nix:15
  ```

# Description

This command opens the Nix expression of a derivation in an
editor. The filename and line number of the derivation are taken from
its `meta.position` attribute. Nixpkgs' `stdenv.mkDerivation` sets
this attribute to the location of the definition of the
`meta.description`, `version` or `name` derivation attributes.

The editor to invoke is specified by the `EDITOR` environment
variable. It defaults to `cat`. If the editor is `emacs`, `nano`,
`vim` or `kak`, it is passed the line number of the derivation using
the argument `+<lineno>`.

)""

Title: Nix Edit Command: Examples and Description
Summary
The `nix edit` command is used to open the Nix expression of a derivation in an editor. It determines the file and line number from the derivation's `meta.position` attribute, which `stdenv.mkDerivation` in Nixpkgs sets based on attributes like `meta.description`, `version`, or `name`. The editor used is specified by the `EDITOR` environment variable (defaulting to `cat`), and common editors like Emacs, Nano, Vim, or Kak receive the line number as a `+<lineno>` argument. Examples demonstrate how to open the `nixpkgs#hello` package and retrieve its `meta.position`.