Basics
Given a hello world example, click on the end of each line to get an explanation:
{ pkgs, ... }: # ``devenv.nix`` is a function with inputs. `pkgs` is an [input](/inputs/) passed as a special argument to the function.
{ # Our function is returning an attribute set, similar to an object in JSON. env.GREET = "hello"; # Attributes can be nested and have similar values as in JSON.
packages = [ pkgs.jq ];
enterShell = '' echo $GREET jq --version ''; # Values can refer to the inputs. See [Inputs](/inputs/) for how to define inputs.}We use a special input ... at the end as a catch-all to avoid enumerating all of the inputs.
2. Our function is returning an attribute set, similar to an object in JSON.
3. Attributes can be nested and have similar values as in JSON.
4. Values can refer to the inputs. See Inputs for how to define inputs.
enterShell allows you to execute bash code once the shell activates, while env allows you to set environment variables.
$ devenv shellBuilding shell ...Entering shell ...
hellojq-1.6
(devenv) $ echo $GREEThelloSee Nix language tutorial for a 1-2 hour deep dive that will allow you to read any Nix file.
Running commands
Section titled “Running commands”Pass a command to devenv shell to run it inside the environment and exit:
$ devenv shell -- git log --onelineFor multiple commands, pipes, or &&, use bash -c:
$ devenv shell -- bash -c 'cd src && make'Shell prompt
Section titled “Shell prompt”To hide the (devenv) prefix, add this to your project’s devenv.yaml or devenv.local.yaml:
prompt_prefix: falseTo disable it globally, set shell.prompt_prefix: false in your user configuration
at ~/.config/devenv/config.yaml (or $XDG_CONFIG_HOME/devenv/config.yaml):
version: 1shell: prompt_prefix: falseThe project setting takes precedence over the global setting. Set prompt_prefix: true in a project
to re-enable the prefix. The default is true.
This setting is useful when managing your prompt with tools such as Starship and takes effect
when you start a new shell.
Environment Summary
Section titled “Environment Summary”If you’d like to print the summary of the current environment:
$ devenv info...
# env- DEVENV_DOTFILE: .../myproject/.devenv- DEVENV_ROOT: .../myproject- DEVENV_STATE: .../myproject/.devenv/state- GREET: hello
# packages- jq-1.6
# scripts
# processes
