Skip to content

Nix

nix is a cross-platform package-manager. nix runs on top of most Linux distributions (Debian, Ubuntu, Redhat, etc) as well as MacOS. Nix packages are stored in a separate folder (/nix), and you can safely run multiple versions of any package.

nix is used by the CI test-infrastructure for civicrm-core.

Major features

These instructions will install the following packages in /nix:

  • Interpreters: PHP-CLI, NodeJS
  • Servers: Apache HTTPD, MySQL, PHP-FPM, MailHog, Redis

Additionally, they will install buildkit in $HOME/buildkit.

Trade-offs
  • Pro: nix runs locally at native speed on Linux+MacOS with x86+arm64. Configuration is packaged, editable, and disposable. Can be combined with desktop tools (IDEs/debuggers). Packages don't interfere with host. Closely matches official test environment.
  • Con: No Windows support (except through WSL/virutalization). Customization requires learning new language. Major host OS updates sometimes have compatibility issues (but usually fixable).

Requirements

  • Linux or MacOS (Note: Generally, you'll get the best results with an OS release that is 3-24 months old -- something recent but not brand new.)
  • x86 or arm64
  • git
  • Sudo privileges

Download

## Download the configuration
git clone https://github.com/civicrm/civicrm-buildkit ~/buildkit

## Download and install the binaries
cd ~/buildkit
./nix/bin/install-developer.sh

The "install-developer.sh" script will download a few gigabytes worth of data.
It may compile some packages from source.

For further discussion about these commands and their variations, see nix/doc/install-developer.md.

Startup

## Open a subshell
use-bknix dfl -s

## Start the services - HTTPD, MySQL, etc
cd ~/buildkit
loco run

The "loco run" command will start HTTPD, MySQL, etc on alternative ports.
This allows them to coexist with any other services you have.

For further discussion about these commands and their variations, see nix/doc/usage-loco.md.

Next steps

Finally, once you are able to work with use-bknix and loco, you can move on to using civibuild.