For GitHub Actions, installing Nix and caching the Nix store is easily done with the following actions:
- uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34, 2025-09-24
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@7df957e333c1e5da7721f60227dbba6d06080569 # v7, 2026-01-08
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-
gc-max-store-size-linux: 2G
purge: true
purge-prefixes: nix-${{ runner.os }}-
purge-created: 0
purge-last-accessed: P1DT12H
purge-primary-key: never
With Forgejo Actions, actions/cache is mirrored from GitHub Actions and offers some limited functionality (docs). I’d like if there were a good Nix store cache story for Forgejo Actions. I’ll work on this eventually, but until that day, this forum post serves as a request for others who might have the same desire.
Related, check out my runs-on: nixos nixos runner for Forgejo Actions:
It compiles and pushes a nixos runner image to registry, then uses that image. The kubenix code for deploying this isn’t entirely open-sourced yet since my secrets management is a mess. I’ll share as soon as it’s ready, for those who are into self-managed kubenix clusters using Talos.
https://simonshine.dk/articles/forgejo-actions-nixos-runners/