Test sonar-scanner-cli

Test sonar-scanner-cli in Nix for NixOS/nixpkgs#329764.

Tools

Nix

Nix is a package manager and build system centered around reproducibility.

For us, Nix's most useful feature is its ability to create reproducible + isolated CLI shells on the same machine which use different versions of the same package (e.g. Java 17 and 21). Shell configurations can be encapsulated in Nix configurations which can be shared across multiple computers.

The best way to install Nix is with the Determinate Nix Installer (guide).

Once installed, running nix develop in a directory with a flake.nix will create a nested Bash shell defined by the flake.

direnv

direnv (🍺) is a shell extension which can automatically load and unload environment variables when you enter or leave a specific directory.

It can automatically load and unload a Nix environment when we enter and leave a project directory.

Unlike nix develop which drops you in a nested Bash shell, direnv extracts the environment variables from the nested Bash shell into your current shell (e.g. Bash, Zsh, Fish).

Follow the installation instructions on its website.

Editor Plugins

Plugins to add editor support for direnv. Note that these won't automatically reload the environment after you change Nix flakes unlike direnv itself so you need to manually trigger a reload.