Nix cache and NixOS CI runners in Forgejo Actions?

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/

3 Likes

I’ve been concerned with the security limitations uncovered in GitHub CI/workflows in recent supply chain attacks, have been looking for ways to completely replace MicroSlop/GitHub tools in my workflow, and also absolutely am looking to deploy on Talos. So this is right up my alley. I’m happy to help when I get some time next month.

2 Likes

have been looking for ways to completely replace MicroSlop/GitHub tools in my workflow

If this is your goal, there are easier ways to get Forgejo running on a VM than via Kubernetes.

I would go with Docker Compose or directly as a NixOS systemd service.

Experimentation is the interesting part.

I care about making more things possible rather than depending on the Docker implicit trust model. I leave docker delivery options open to potential collaborators in my projects but prefer to eschew Docker wherever possible for MANY reasons (mostly philosophical); the whole reason I use Nix.

1 Like