Projects like Ema enable creating your own static-site generator in Haskell, while leveraging Nix for reproducibility. The challenge with deploying your Haskell-based static site on GitHub Pages, however, is the lack of Nix caching. Every time you update your site, the CI will run slowly due to having to:
- Download, and rebuild any Haskell dependencies overriden in the Nix file
- Rebuild the static site Haskell project itself
Now, if you are scheduling generation of site (presumably because the input to your site is fetched afresh from the internet), then the above steps will re-run needlessly. This can be avoided by decoupling the
The build step
The build step should run
nix-build, effectively - and then use Nix’s docker infrastructure to produce a Docker image out of it and push it to a remote (Docker Hub or GitHub’s image registry).
The generate step
The generate step of the CI would then use the latest Docker image from the registry and simply “run” your project. There is no compilation whastoever involved here, so it completes instantly.
- First step illustration: build.yaml
- Second step illustration: cron.yaml (generate)