nix-gitlab-ci/docs/caching.md
technofab cf80010d07 docs: write docs & improve tooling
Squashed commit of the following:

commit 86eadd3ec42b7bce0dc5716d65798af95d0d8cbc
Author: technofab <admin@technofab.de>
Date:   Fri May 2 17:10:33 2025 +0200

docs(README): fix built with nix badge

commit f50057da69e89974f17bc37b5e140b2ef9f817f6
Author: technofab <admin@technofab.de>
Date:   Fri May 2 16:09:00 2025 +0200

ci: change back rule so docs only get deployed on main

commit ce02b043f4bd83c36285e5620e71701fc3bcc998
Author: technofab <admin@technofab.de>
Date:   Fri May 2 16:08:10 2025 +0200

docs: write docs and improve formatter etc.

commit e996b23cf877d8021759b782aa5996f5e2bf12ac
Author: technofab <admin@technofab.de>
Date:   Fri May 2 16:07:56 2025 +0200

docs: update README

commit 650f97b5608c32cf6cf66cc3fdd0965dc42e4860
Author: technofab <admin@technofab.de>
Date:   Wed Apr 23 21:05:14 2025 +0200

docs: add favicon

commit 67e1bfecbcaf0b8f7dad2eecfaccf774cc560874
Author: technofab <admin@technofab.de>
Date:   Wed Apr 23 20:53:44 2025 +0200

docs: initial setup
2025-05-02 17:30:53 +02:00

1.5 KiB

Caching

Nix GitLab CI supports several caching mechanisms to speed up your pipelines.

GitLab Runner Cache

The runner cache strategy copies the new store paths into a directory .nix-cache, which is then saved in the regular GitLab cache (technically runner cache). It's also configured as a substituter automatically.

To enable, set the cache strategy to runner.

Configure it using these environment variables:

  • RUNNER_CACHE: path to the runner cache (default .nix-cache)

!!! warning

This is very inefficient and should probably only be used for very very small
dependency counts. Otherwise it takes an eternity to save to cache.

Cachix

Cachix is a hosted binary cache service that can significantly speed up Nix builds by sharing build results.

To enable, set the cache strategy to attic.

Configure it using these environment variables:

  • CACHIX_CACHE: name of the cache to use
  • (CACHIX_AUTH_TOKEN): cachix client itself uses this for authentication

!!! warning

Cachix has not been tested. Feedback is appreciated :)

Attic (Self-Hosted Cache)

Attic is a self-hosted, deduplicating binary cache. It's a great option if you want more control over your caching infrastructure and to have the cache closer to your runners.

To enable, set the cache strategy to attic.

Configure it using these environment variables:

  • ATTIC_SERVER: URL of the server
  • ATTIC_CACHE: name of the cache to use
  • ATTIC_TOKEN: auth token from the attic server