Skip to content

nix at railbird

We use the nix build-tool/package manager extensively at railbird in all of our components.

Getting nix

The easiest way to get nix is to use the determinate nix installer:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Flakes

We use flakes at railbird, which is a feature of nix that is technically considered experimental. The determinate installer usually enables the flakes feature by default, but if you get nix from anywhere else, you may need to enable it manually.

Allowing unfree sources

Nix requires that you explicitly indicate that you want to allow the installation of unfree software. We use several such packages at railbird, so you will have to opt in. The most permanent way to do this is by adding

{ allowUnfree = true; }

to ~/.config/nixpkgs/config.nix (you need to create that file first). Because flakes are completely hermetic by default, and this is technically a piece of external state, we have to run all of our flakes with the --impure flag.

You can also allow unfree sources in a more transient way by setting:

export NIXPKGS_ALLOW_UNFREE=1

or by prefixing your command with the same, e.g.

NIXPKGS_ALLOW_UNFREE=1 nix develop --impure

direnv

direnv is a piece of software that automatically loads directory specific configuration into your shell. It pairs really nicely with nix and will make it so that you don't need to worry about making sure to run nix develop --impure when working on railbird projects. It is highly recommended that you get it working, but requires modifying your shell startup.

Verify nix install works

nix --version

nix-channel --list

nix-env --list-generations

nix-shell -p hello --run "hello"

nix flake show github:nixos/nixpkgs