Description
When using GHA to turn iohk/devx
into a shell to run, e.g. cabal update, cabal build
, we take a lot of time downloading stuff.
A lot of this time comes down to nix sequentially downloading a lot of data. We should build the store and export/import it instead to speed this up.
nix path-info --closure-size --human-readable $(nix print-dev-env --json .#ghc8107-static-minimal | jq -r .variables.out.value)
… will give us something like 2.5G
. That's a lot.
We can also enter the shell using
$ nix print-dev-env .#ghc8107-static-minimal > env.sh
$ bash --rcfile env.sh
(e.g. instead of nix develop
).
We could pre-build the closure (e.g. from result
), and store that as a zstd
compressed archive:
nix-store --export $(nix-store -qR result) | zstd -z8T8 > out.zstd
And then re-import this as the first step in GHAs after setting up nix.
See for example this GHA: https://github.com/angerman/x/blob/c559ae0429bb69829a9c9cae8c21ab777461aaf2/.github/workflows/main.yml#L23-L66, which doesn't work properly yet (nix still ends up downloading stuff when trying to enter the shell; maybe this can be eliminated with the env.sh
idea from above).