2020-12-08 22:52:22 +02:00
|
|
|
R""(
|
|
|
|
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
* Start a shell with the build environment of the default package of
|
|
|
|
the flake in the current directory:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# nix develop
|
|
|
|
```
|
|
|
|
|
|
|
|
Typical commands to run inside this shell are:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# configurePhase
|
|
|
|
# buildPhase
|
|
|
|
# installPhase
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternatively, you can run whatever build tools your project uses
|
|
|
|
directly, e.g. for a typical Unix project:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# ./configure --prefix=$out
|
|
|
|
# make
|
|
|
|
# make install
|
|
|
|
```
|
|
|
|
|
|
|
|
* Run a particular build phase directly:
|
|
|
|
|
|
|
|
```console
|
2021-10-09 01:19:50 +03:00
|
|
|
# nix develop --unpack
|
2020-12-08 22:52:22 +02:00
|
|
|
# nix develop --configure
|
|
|
|
# nix develop --build
|
|
|
|
# nix develop --check
|
|
|
|
# nix develop --install
|
|
|
|
# nix develop --installcheck
|
|
|
|
```
|
|
|
|
|
|
|
|
* Start a shell with the build environment of GNU Hello:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# nix develop nixpkgs#hello
|
|
|
|
```
|
|
|
|
|
|
|
|
* Record a build environment in a profile:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# nix develop --profile /tmp/my-build-env nixpkgs#hello
|
|
|
|
```
|
|
|
|
|
|
|
|
* Use a build environment previously recorded in a profile:
|
|
|
|
|
2020-12-09 00:01:50 +02:00
|
|
|
```console
|
2020-12-08 22:52:22 +02:00
|
|
|
# nix develop /tmp/my-build-env
|
|
|
|
```
|
|
|
|
|
2022-01-30 10:51:39 +02:00
|
|
|
* Replace all occurrences of the store path corresponding to
|
2020-12-08 22:52:22 +02:00
|
|
|
`glibc.dev` with a writable directory:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# nix develop --redirect nixpkgs#glibc.dev ~/my-glibc/outputs/dev
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that this is useful if you're running a `nix develop` shell for
|
|
|
|
`nixpkgs#glibc` in `~/my-glibc` and want to compile another package
|
|
|
|
against it.
|
|
|
|
|
2022-09-06 18:18:13 +03:00
|
|
|
* Run a series of script commands:
|
|
|
|
|
|
|
|
```console
|
2023-09-12 18:15:36 +03:00
|
|
|
# nix develop --command bash -c "mkdir build && cmake .. && make"
|
2022-09-06 18:18:13 +03:00
|
|
|
```
|
|
|
|
|
2020-12-08 22:52:22 +02:00
|
|
|
# Description
|
|
|
|
|
|
|
|
`nix develop` starts a `bash` shell that provides an interactive build
|
|
|
|
environment nearly identical to what Nix would use to build
|
2022-12-01 02:57:02 +02:00
|
|
|
[*installable*](./nix.md#installables). Inside this shell, environment variables and shell
|
2020-12-08 22:52:22 +02:00
|
|
|
functions are set up so that you can interactively and incrementally
|
|
|
|
build your package.
|
|
|
|
|
|
|
|
Nix determines the build environment by building a modified version of
|
|
|
|
the derivation *installable* that just records the environment
|
|
|
|
initialised by `stdenv` and exits. This build environment can be
|
|
|
|
recorded into a profile using `--profile`.
|
|
|
|
|
|
|
|
The prompt used by the `bash` shell can be customised by setting the
|
2022-05-10 23:55:25 +03:00
|
|
|
`bash-prompt`, `bash-prompt-prefix`, and `bash-prompt-suffix` settings in
|
|
|
|
`nix.conf` or in the flake's `nixConfig` attribute.
|
2020-12-08 22:52:22 +02:00
|
|
|
|
|
|
|
# Flake output attributes
|
|
|
|
|
2021-07-13 12:44:19 +03:00
|
|
|
If no flake output attribute is given, `nix develop` tries the following
|
2020-12-08 22:52:22 +02:00
|
|
|
flake output attributes:
|
|
|
|
|
2022-02-22 15:32:56 +02:00
|
|
|
* `devShells.<system>.default`
|
2020-12-08 22:52:22 +02:00
|
|
|
|
2022-02-22 15:32:56 +02:00
|
|
|
* `packages.<system>.default`
|
2020-12-08 22:52:22 +02:00
|
|
|
|
2021-07-13 12:44:19 +03:00
|
|
|
If a flake output *name* is given, `nix develop` tries the following flake
|
|
|
|
output attributes:
|
|
|
|
|
|
|
|
* `devShells.<system>.<name>`
|
|
|
|
|
|
|
|
* `packages.<system>.<name>`
|
|
|
|
|
|
|
|
* `legacyPackages.<system>.<name>`
|
|
|
|
|
2020-12-08 22:52:22 +02:00
|
|
|
)""
|