LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix3-develop

enters development shells

TLDR

Enter the dev shell of the flake in the current directory
$ nix develop
copy
Enter a named dev shell
$ nix develop [.#devShellName]
copy
Get the build environment of a nixpkgs package
$ nix develop nixpkgs#[hello]
copy
Run a command in the dev shell instead of an interactive shell
$ nix develop --command [make]
copy
Run a series of commands
$ nix develop --command bash -c "[mkdir build && cd build && cmake .. && make]"
copy
Run a single build phase directly
$ nix develop --build
copy
Start with a clean environment, keeping selected variables
$ nix develop --ignore-env --keep-env-var [HOME]
copy
Save the environment to a profile for reuse and GC protection
$ nix develop --profile [/tmp/dev-env]
copy

SYNOPSIS

nix develop [options] [installable]

DESCRIPTION

nix3-develop is the manual page for nix develop, which starts a bash shell with the build environment of a derivation: the variables and shell functions stdenv would set up when building it. Flakes usually define a dedicated devShells output with the tools a project needs.Nix obtains the environment by building a modified derivation that only records the environment and exits. The prompt can be customised with the bash-prompt, bash-prompt-prefix and bash-prompt-suffix settings.

PARAMETERS

INSTALLABLE

Flake reference and output. Defaults to devShells.<system>.default, then packages.<system>.default of the flake in the current directory.
-c, --command CMD ARGS
Run the command instead of an interactive shell.
--unpack, --configure, --build, --check, --install, --installcheck
Run that stdenv phase directly.
--phase NAME
Run the named stdenv phase.
--profile PATH
Record the build environment in a profile, or use one previously recorded.
--redirect INSTALLABLE DIR
Replace a store path with a mutable directory in the environment.
-i, --ignore-env
Clear the environment, except variables given with --keep-env-var.
-k, --keep-env-var NAME
Keep the variable when using --ignore-env.
-s, --set-env-var NAME VALUE
Set an environment variable.
-u, --unset-env-var NAME
Unset an environment variable.
--impure
Allow impure evaluation.
--help
Display help information.

INSTALL

sudo apt install nix-bin
copy
sudo dnf install nix
copy
sudo pacman -S nix
copy
sudo apk add nix
copy
sudo zypper install nix
copy
nix profile install nixpkgs#nix
copy

CAVEATS

There is no nix3 executable: the new-CLI man pages are named nix3-subcommand to avoid clashing with the old nix-* tools. Read it with man nix3-develop or nix develop --help.Requires the nix-command and flakes experimental features. Always starts bash, regardless of your login shell; use --command or a tool like direnv with nix-direnv to use another shell.

HISTORY

nix develop was introduced with flakes in Nix 2.4 (2021) as the successor to nix-shell for development environments.

SEE ALSO

RESOURCES

Copied to clipboard
Kai