This guide explains how to use Nix to set up a reproducible development environment for cashd. Using Nix eliminates the need to manually install utilities and ensures consistent tooling across different machines.
The Nix development shell is the recommended way to develop cashd. It unifies the development environment for everyone and synchronizes updates: the same tooling and compiler versions are used both here and in CI. Any custom environment (Homebrew packages or anything else) will continue to work, but then it is up to you to keep it in sync with the environment used in CI.
Please follow the official installation instructions of nix package manager for your system.
From the root of the cashd repository, enter the default development shell:
nix --experimental-features 'nix-command flakes' develop
This will:
The first time you run this command, it will take a few minutes to download and build the environment. Subsequent runs will be much faster.
nix develop gives you a shell with all the tooling necessary to
develop cashd and with GCC 15.2 (also provided by Nix). There are no caveats.nix develop gives you a full environment too. The compiler is
your system-wide Apple Clang, while every other tool — including Conan — is
provided by Nix. Conan has no binary in the Nix cache for macOS, so it is
built from source the first time you enter the shell, which makes the initial
setup slower (this is handled automatically; see
nix/devshell.nix).[!TIP] To avoid typing
--experimental-features 'nix-command flakes'every time, you can permanently enable flakes by creating~/.config/nix/nix.conf:mkdir -p ~/.config/nix echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.confAfter this, you can simply use
nix developinstead.
[!NOTE] The examples below assume you’ve enabled flakes in your config. If you haven’t, add
--experimental-features 'nix-command flakes'after eachnixcommand.
A compiler can be chosen by providing its name with the .# prefix, e.g. nix develop .#gcc15.
Use nix flake show to see all the available development shells.
Use nix develop .#no-compiler to use the compiler from your system.
# Use GCC 14
nix develop .#gcc14
# Use Clang 19
nix develop .#clang19
# Use default for your platform
nix develop
nix develop opens bash by default. To use another shell, pass it with the -c flag — this works with any shell, e.g. zsh or fish:
# Use zsh
nix develop -c zsh
# Use fish
nix develop -c fish
# Use your login shell
nix develop -c "$SHELL"
[!WARNING] Your shell’s interactive startup files (e.g.
config.fish,.zshrc) may prepend other directories — most commonly Homebrew — to$PATH, which can shadow the tools provided by the Nix shell. After entering, verify that tools resolve into the Nix store:command -v cmake # should print a /nix/store/... pathIf it doesn’t, either adjust your shell configuration so it doesn’t override
$PATH, or use direnv (below), which loads the environment after your shell config and so takes precedence regardless of the shell you use.
Once inside the Nix development shell, follow the standard build instructions. The Nix shell provides all necessary tools (CMake, Ninja, Conan, etc.).
direnv or nix-direnv can automatically activate the Nix development shell when you enter the repository directory.
This is also the most robust way to use the environment from any shell (bash, zsh, fish, …): direnv stays in your current shell and loads the environment after your shell’s startup files have run, so the Nix-provided tools take precedence over anything your shell configuration adds to $PATH. To use it, install direnv for your shell, then add an .envrc containing use flake at the repository root and run direnv allow.
Please note that there is no guarantee that binaries from conan cache will work when using nix. If you encounter any errors, please use --build '*' to force conan to compile everything from source:
conan install .. --output-folder . --build '*' --settings build_type=Release
flake.lock fileTo update flake.lock to the latest revision use nix flake update command.
See Troubleshooting Nix problems for common issues,
such as nix develop failing inside Git worktrees.