Should the Nix CI do caching
@peterbecich You added a Nix CI: https://github.com/haskell/hackage-server/blob/2d4f3f7fe3a5e38cb959eea139160caf273227ac/.github/workflows/nix-shell.yml#L16-L18
Does this cache between builds?
If not, would caching be possible, maybe along the lines of: https://github.com/cachix/install-nix-action#how-do-i-add-a-binary-cache
I am asking because the Nix workflow takes at least 17min each time, whereas Haskell CI can get down to <10min (probably thanks to caching). (Haskell CI takes long when it cannot restore from the cache, see e.g.: https://github.com/haskell/hackage-server/runs/6437475007?check_suite_focus=true#step:16:23)
Good idea, working on it
It doesn't seem to produce an improvement to use https://github.com/cachix/install-nix-action#how-do-i-add-a-binary-cache
It would be an improvement to have actions/[email protected] working and cache /nix/store in Github; I'm trying to make this work: https://github.com/cachix/install-nix-action/issues/56#issuecomment-1030697681
The current errors are:
...
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/sbin:
Cannot create symlink to ‘bin’: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/xtrace:
Cannot open: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/zic:
Cannot open: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/getent:
Cannot open: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/ldd:
Cannot open: File exists
...
https://github.com/peterbecich/hackage-server/runs/6567988004?check_suite_focus=true
As far as I can tell, the Cachix GitHub Action (https://github.com/cachix/install-nix-action) is designed to only cache on Cachix, and is not compatible with https://github.com/actions/cache
Can we set up a free Cachix account for hackage-server (https://www.cachix.org/pricing)? If you set secrets.CACHIX_SIGNING_KEY and secrets.CACHIX_AUTH_TOKEN in GitHub, then I should be able to implement this https://nix.dev/tutorials/continuous-integration-github-actions#setting-up-github-actions
Can we set up a free Cachix account for
hackage-server(cachix.org/pricing)?
I suppose yes. The conditions are:
Users have a free 5 GB limit for open source projects.
Should be enough. i.i.r.c. the GitHub caching action indicated this needs less than three GB. (It progressed far enough to inform me of that, but nonetheless could not successfully use the cache.)
I created a personal account on cachix.org, but when I created organization hackage-server, I am told that this isn't free (except for a 14 day trial).
Maybe it makes sense for you @peterbecich to set up the account there, since you will (supposedly) maintain the nix CI? If you need more rights on hackage-server to set up the connection, @gbaz is your man.
Does this work yet? I see cachix cache jumping into action, but the build time is still 20min: https://github.com/haskell/hackage-server/runs/6777589545?check_suite_focus=true
Apparently it is not working yet, I'll try a few more things: https://github.com/haskell/hackage-server/pull/1086
Note that I've granted hackage-server organization 50GB free plan, let me know if that's enough!
Thank you @domenkozar , I think 50GB is more than enough
I have another project https://github.com/peterbecich/halogen-chess which has a GitHub Action for a Nix build.
It uses haskell.nix https://github.com/input-output-hk/haskell.nix .
The build time of that GitHub Action has decreased from 3 hours down to 15 minutes by moving the project to Nix Flakes: https://github.com/peterbecich/halogen-chess/actions/workflows/nix-cabal.yml
I know that hackage-server does not use haskell.nix so it is not directly applicable, but perhaps we can move to Flakes another way.
I expect this will yield an improvement: https://github.com/haskell/hackage-server/pull/1154
Cachix works for the Nix Flake
...
copying path '/nix/store/fgmxd2hkkchwlh8jdgc1h1z0v0kk4yi5-optparse-applicative-0.15.1.0-doc' from 'https://hackage-server.cachix.org/'...
...
https://github.com/haskell/hackage-server/actions/runs/4411857013/jobs/7730762854
down to 8 minutes, https://github.com/haskell/hackage-server/actions/runs/4550618189 I think the caching is working, closing issue