Skip to content

Should the Nix CI do caching #1078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreasabel opened this issue May 18, 2022 · 13 comments · Fixed by #1081
Closed

Should the Nix CI do caching #1078

andreasabel opened this issue May 18, 2022 · 13 comments · Fixed by #1081
Assignees
Labels
re: CI Concerning continuous integration (CI) re: nix Concerning Nix stuff

Comments

@andreasabel
Copy link
Member

@peterbecich You added a Nix CI:

- uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-21.11

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)

@andreasabel andreasabel added re: CI Concerning continuous integration (CI) re: nix Concerning Nix stuff labels May 18, 2022
@peterbecich
Copy link
Member

peterbecich commented May 24, 2022

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: cachix/install-nix-action#56 (comment)

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

@peterbecich
Copy link
Member

peterbecich commented May 24, 2022

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

@andreasabel
Copy link
Member Author

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.

@peterbecich
Copy link
Member

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.)

@andreasabel
Copy link
Member Author

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.

@gbaz gbaz closed this as completed in #1081 Jun 4, 2022
@andreasabel
Copy link
Member Author

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

@andreasabel andreasabel reopened this Jun 7, 2022
@peterbecich
Copy link
Member

Apparently it is not working yet, I'll try a few more things: #1086

@domenkozar
Copy link

Note that I've granted hackage-server organization 50GB free plan, let me know if that's enough!

@peterbecich
Copy link
Member

Thank you @domenkozar , I think 50GB is more than enough

@peterbecich
Copy link
Member

peterbecich commented Oct 30, 2022

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.

@peterbecich
Copy link
Member

I expect this will yield an improvement: #1154

@peterbecich
Copy link
Member

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

@peterbecich
Copy link
Member

down to 8 minutes, https://github.com/haskell/hackage-server/actions/runs/4550618189 I think the caching is working, closing issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: CI Concerning continuous integration (CI) re: nix Concerning Nix stuff
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants