GitHub Action
Nix Quick Install
This GitHub Action installs Nix in single-user mode, and adds almost no time at all to your workflow's running time.
The Nix installation is deterministic – for a given release of this action the resulting Nix setup will always be identical, no matter when you run the action.
-
Supports Linux and MacOS runners
-
Single-user installation (no
nix-daemon
) -
Installs in ≈ 1 second on Linux, ≈ 5 seconds on MacOS
-
Allows selecting Nix version via the
nix_version
input -
Allows specifying
nix.conf
contents via thenix_conf
input
The main motivation behind this action is to install Nix as quickly as possible in your GitHub workflow. If that isn't important, you should probably use the Install Nix action instead, which sets up Nix in multi-user mode (daemon mode) using the official Nix installer.
To make this action as quick as possible, the installation is minimal: no
nix-daemon, no nix channels and no NIX_PATH
. The nix store (/nix/store
) is
owned by the unprivileged runner user.
The action provides you with a fully working Nix setup, but since no NIX_PATH
or channels are setup you need to handle this on your own. Nix Flakes is great
for this, and works perfectly with this action (see below).
niv should also work fine, but has not been
tested yet.
See action.yml for documentation of the available inputs. The available Nix versions are listed in the release notes.
The following workflow installs Nix and then just runs
nix-build --version
:
name: Examples
on: push
jobs:
minimal:
runs-on: ubuntu-latest
steps:
- uses: nixbuild/nix-quick-install-action@v5
- run: nix-build --version
To be able to use Nix flakes you need to specify a version of Nix that supports it, and also enable the flakes functionality in the nix configuration:
name: Examples
on: push
jobs:
flakes-simple:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nixbuild/nix-quick-install-action@v5
with:
nix_version: 2.4pre20201205_a5d85d0
nix_conf: experimental-features = nix-command flakes
- name: nix build
run: nix build ./examples/flakes-simple
- name: hello
run: ./result/bin/hello
You can see the flake definition for the above example in examples/flakes-simple/flake.nix.
You can use the Cachix action together with this action, just make sure you put it after this action in your workflow.