Installing Nix on Github Actions

I’ve been using Nix on GitHub Actions like so:

name: My Workflow
on: [push]

    runs-on: ubuntu-latest
      - uses: actions/checkout@master
      - name: nix
        run: |
          curl | sh

However, almost every third or fourth run on GitHub Actions has led to a segfault in the installation.

Are there some alternatives that I should know about for installing Nix in GitHub Actions?

Please, no Docker/container-related suggestions, unless to show an existing, working setup using the NEW Actions workflow.

Hi, I was in the initial beta of GitHub Actions. I don’t know if this will be of use, but here’s what I initially did:

Though, the action-nix-build action isn’t that useful compared to just using the standard Docker image from Nixos.

The only benefit is how it auto-calls release.nix or default.nix by default (unless given a command to run) and then copies the contents of the result link.

Since you cannot (or could not at that moment in time) overlay mount on top of the nix store, there’s quite a few limitations. You either need to rely on external caching like cachix, or have a simple enough build that outputs files only in result. Alternatively, it should be possible to do something with copy-closure, but I kinda lost interest since it wasn’t really meshing well with the other actions.

Just a (perhaps) related data point – this also happens on Travis-CI. I encounter this quite regularly. Sometimes this happens during installation, but also during e.g. channel updates:

There’s also this issue:

But the reporter does not seem to have filed an issue in the Nix repo.

1 Like

If the problem is only in the installation step, have you considered using the statically compiled Nix from Static Nix: a command-line swiss army knife ?

I wasn’t able to reproduce the issue with docker. Any idea how it could be done in a more fully-fledged VM?


FROM debian:latest

RUN apt update -q
RUN apt install -qy bzip2 curl vim sudo

# create a default user
RUN yes | adduser -q zimbatm
RUN echo "zimbatm ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/zimbatm

# switch to user, set USER to make the nix install script happy
ENV USER=zimbatm
USER zimbatm
i=0; id=$(docker build .); while docker run -ti --rm --privileged 4a0f74255254  sh -c "curl | sh && . /home/zimbatm/.nix-profile/etc/profile.d/ && NIX_PATH=nixpkgs=channel:nixos-unstable nix-channel --update"; do ((i++)); echo "************** $i *****************"; done