aboutsummaryrefslogtreecommitdiff
path: root/src/nix/print-dev-env.md
blob: a7b1cc2b679bb3e3bffcc93a628cc7c17d5cec1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
R""(

**Note:** this command's interface is based heavily around [*installables*](./nix.md#installables), which you may want to read about first (`nix --help`).

# Examples

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

  ```console
  # . <(nix print-dev-env nixpkgs#hello)
  ```

* Get the build environment in JSON format:

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

  The output will look like this:

  ```json
  {
    "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*](./nix.md#installables). 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.

)""