Move away from static-haskell-nix
We currently build a static PostgREST executable using https://github.com/nh2/static-haskell-nix. I think we should try moving away from that because
- the project appears to be abandoned
- the dependency makes it very difficult to upgrade nixpkgs
(This isn't really a new idea, I just wanted to file a central issue for tracking this.)
Some references:
- https://github.com/PostgREST/postgrest/issues/2327
- https://github.com/NixOS/nixpkgs/issues/43795
- https://github.com/NixOS/nixpkgs/issues/61575
- https://discourse.haskell.org/t/portable-haskell-executables-anyone-doing-that-possibly-using-nix/4816
- https://github.com/PostgREST/postgrest/pull/2332
I've done a bit of digging into pkgs.pkgsStatic today:
- https://github.com/NixOS/nixpkgs/pull/191915
- https://github.com/NixOS/nixpkgs/issues/191920
It looks like pkgsStatic goes quite a bit further than what we need to build a static PostgREST -- it builds a fully static package set, so it requires all PostgREST dependencies to build in a fully static environment, while all we need is the static build artifacts of all dependencies. E.g., this builds postgresql in an environment where only static libraries exist, which the build system seems not prepared for. We only need dontDisableStatic = true for our dependencies.
The glcr.b-data.ch/ghc/ghc-musl images may be an alternative.
👉 https://github.com/benz0li/ghc-musl
static-haskell-nix has recently seen some work again, with an update to nixos-23.05: https://github.com/nh2/static-haskell-nix/pull/116