lix/src/nix/print-dev-env.md
Qyriad 194ba8a02f docs: guide to installables docs in installable commands' docs
The installables syntax is not documented in any of the man pages or
docbook pages for any of those individual commands. And while these
commands really should at least peripherally individually document how
installables work, in the meantime we can at least direct people to the
right place.

This commit also clarifies the unexpected fact that `nix profile remove`
and `nix profile upgrade` do *not* take installables.

Change-Id: I3b1453cb197a613bbab639c66a466365c3592c6d
2024-04-29 08:06:05 -06:00

1.3 KiB

R""(

Note: this command's interface is based heavily around installables, which you may want to read about first (nix --help).

Examples

  • Apply the build environment of GNU hello to the current shell:

    # . <(nix print-dev-env nixpkgs#hello)
    
  • Get the build environment in JSON format:

    # nix print-dev-env nixpkgs#hello --json
    

    The output will look like this:

    {
      "bashFunctions": {
        "buildPhase": " \n    runHook preBuild;\n...",
        ...
      },
      "variables": {
        "src": {
          "type": "exported",
          "value": "/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz"
        },
        "postUnpackHooks": {
          "type": "array",
          "value": ["_updateSourceDateEpochFromSourceRoot"]
        },
        ...
      }
    }
    

Description

This command prints a shell script that can be sourced by bash and that sets the variables and shell functions defined by the build process of installable. This allows you to get a similar build environment in your current shell rather than in a subshell (as with nix develop).

With --json, the output is a JSON serialisation of the variables and functions defined by the build process.

)""