This commit is contained in:
Quentin 2023-03-24 17:04:19 +01:00
parent 2e69313a12
commit 9591374838
Signed by: quentin
GPG Key ID: E9602264D639FF68
9 changed files with 7 additions and 14 deletions

View File

@ -59,20 +59,13 @@ And... that's basically all you need.
### A NixOS builder with local cache
The nix builder will create a local cache on your node agent at `/var/cache/albatros`.
It will create two folders: `/var/cache/albatros/nix` that contains a nix store,
and `/var/cache/albatros/cacheroot` that contains nix roots, ie. the builds we must keep.
Caching is handled thanks to these roots: roots that are older than 7 days will be removed,
then a garbage collection will be triggered, and their associate content will be deleted.
To keep your cache between builds, you must put your outlink in `/mnt/cacheroot` with a unique name.
The git commit is a good candidate:
```bash
# create an output link at a persisted path
nix build --out-link $GCROOT
```
In the `hcl/` folder, you will find the definition of a builder named `nixcache`.
This builder has the following features:
- It creates a persisted nix store at `/var/cache/albatros` on your host if it does not exist yet.
- The nix store is mounted read-only during the build
- A nix daemon is run in a separate container, you can interact with it though its unix socket (everything is already setup for you). Simply run `nix build`.
- All your builds are automatically added as a nix gcroots by the nix daemon, `keep_derivation` is activated so your build dependencies are kept locally.
- At the end, all gcroots older than 7 days are deleted, and then the `nix store gc` is called effectively wiping data that were previously attached to old gcroots.
## Register a build