The mentioned cachix (you can also create S3 bucket that can also provide similar functionality).
If you set up gitlab runner in NixOS [1], you can follow example configuration which allows to utilize nix local caching.
You can of course also use the normal gitlab caching, you will need to ensure the container has /cache mount.
[1] https://search.nixos.org/options?channel=21.05&from=0&size=5...
[1] https://github.com/NixOS/nixpkgs/blob/ce38fecabe49a76fcd08d0...
https://cachix.org/ provides some off the shelf services.
There's a few blog posts about using AWS S3 as a binary cache so you can roll your own.
There's a few blog posts about using AWS S3 as a binary cache so you can roll your own.
Unfortunately, this is really slow due to Nix using Brotli compression at a high compression level. There were some PRs to make the compression method configurable, but the last time I checked, none of them were merged.
It is not really an issue if your outputs are small. But I had a private S3 cache and have some derivations that have large output paths, and it made CI excruciatingly slow.
If you are on AWS you can also set up S3 bucket.