This GitHub Action installs Nix in single-user mode, and adds almost no time at all to your workflow's running time.
For the moment, this action only support Linux runners.
There are inputs for selecting which Nix version to use, and to specify
nix.conf
contents. 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.
The main motivation behind this action is to install Nix as quickly as possible in your GitHub workflow. If that isn't important (for example, if the other steps in the workflow takes much longer time than the Nix installer), you should probably use the Install Nix action instead, which sets up Nix in multi-user mode (daemon mode), has support for MacOS and is also very quick.
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@v2
- 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@v2
with:
nix_version: 3.0pre20200829_f156513
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.