-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add static build with Nix (fixes #1295) #1494
Add static build with Nix (fixes #1295) #1494
Conversation
f815305
to
d9a1aa4
Compare
Note: Now that we have CI integration, this will be picked up and built through CircleCI - this will take ages, as there are no cached binaries for all the Musl based build that we defined here. This will become better once the PR is merged and builds are pushed to cachix. @steve-chavez : If you have a halfway powerful machine, you could speed up the process by running |
Regarding building on GHC 8.8.3: This previously failed due to NixOS/nixpkgs#85924 . A temporary fix is to revert a commit that changed what the build of GHC is bootstrapped with (see details in the linked issue). Until there is a proper fix, I pinned a version of Nixpkgs where that one commit is reverted. Not very pretty, but the building of static executables in Haskell is still a bit experimental. |
@monacoremo Building now! I've ran |
@monacoremo Got an error:
Did you saw this when building the static bin? Looks like the last line comes from cachix: cachix/cachix#173. Though the libuv failure seems unrelated. |
These are the libuv tests that fail:
Seems related to libuv/libuv#2468. Maybe this gives a hint on how to solve the issue: NixOS/nixpkgs#79331. |
@steve-chavez Hm, that's weird - as far as I remember the compile went through for me back then. I'll have access to my desktop again next week, will then try to recompile and see what the issue is! |
@monacoremo Seems it was a firewall issue. Got the hint from libuv/libuv#2827 (comment). I did |
The build was successful! nix-build -j 8 --cores 2 -A postgrestStatic | cachix push postgrest
All done.
ldd result/bin/postgrest
not a dynamic executable Also, the cachix storage for postgrest looks like this: I'm guessing the build results got uploaded fine. @monacoremo Rebase and I'll merge :) |
d9a1aa4
to
e8c4d5c
Compare
e8c4d5c
to
16df833
Compare
@steve-chavez Awesome! I rebased and added a small tweak: The required fixes to Nixpkgs and static-haskell-nix are now included as patches, instead of pinning forked versions of the repositories. This should be easier to maintain. Also with that tweak, nix-shell does not depend on the patched Nixpkgs anymore. Accordingly, the normal version of GHC that is available in the general binary cache will be used, which will be faster for users not building static executables. Edit: Even though this results in the same static binary, it changed the hash of our Musl GHC and all derivations that build on it, so the CI will have to re-do a lot of work and take a very long time... :-) We might hit some maximum build time with CircleCI, in that case it would be best if you could build and push to cachix locally again. Edit 2: Actually, not sure why it had to rebuild all the Musl stuff from the ground up... did it pick up the cachix cache at all? I'll try that locally also. |
@monacoremo Patches look better :] I've done
I'm not sure, but the CircleCI job went for 5 hours 😮. Looks like it didn't pick up the cache. |
@steve-chavez Hm, it's possible that some build dependencies were not pushed to the cache with the command above. I tried to add the Could you try to run
|
@monacoremo I did:
It took a while to finish, but it's done now. Now the cachix storage shows 2.89GB(!). Do you think that now the CI build will be fast? |
@steve-chavez Looking good!! :-) |
@monacoremo Great! Up next, I'll integrate the static bin with the release process. I'm thinking I could remove the centos7/ubuntu releases and prefer the new static bin. Those releases failed from time to time(package managers with outdated urls). The ubuntui386 would remain though. Or maybe we can build the static bin for 32 bit somehow? |
@steve-chavez In principle it would be possible to cross-compile a static 32 bit executable by using `pkgs.pkgsCross.musl32', but I ran into issues when I just tried that... Might be easier to stick with the Docker based build for now for 32 bit. |
* Include modifications to nixpkgs and static-haskell-nix as patches. * use the patched static-haskell-nix version * Add cachix postgrest
Building a static executable works, but there are two issues remaining that would be nice to get fixed:
nix/postgrest.nix
that was pre-generated withcabal2nix
- would be better to avoid that by usingcallCabal2nix
as we do for the dynamic derivation, but I was not able to get that to work yet. Update: fixed with e6eb775