Zig2nix: nix flake for packaging, building and running Zig projects

Inspired by GitHub Actions: mlugg/setup-zig
To have good caching on github actions for your zig2nix projects, you can use these 2 actions:

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

The first one installs nix, the second one caches the /nix/store.
The action automatically avoids caching anything that’s already cached in the official binary cache of nixpkgs.
All build.zig.zon dependencies will be cached as well if you use zig2nix’s package functions.

The caching can be seen in in action for example in the zig2nix repository itself:
https://github.com/Cloudef/zig2nix/actions/caches

One caveat is this currently caches even small outputs, which I’ve filled a issue:
https://github.com/DeterminateSystems/magic-nix-cache-action/issues/31
PR fixing it https://github.com/DeterminateSystems/magic-nix-cache/pull/69

2 Likes