Skip to content
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

postgrest static build support #1295

Closed
clojurians-org opened this issue May 16, 2019 · 22 comments
Closed

postgrest static build support #1295

clojurians-org opened this issue May 16, 2019 · 22 comments
Labels
ci Related to CI setup

Comments

@clojurians-org
Copy link

clojurians-org commented May 16, 2019

currently the postgrest executable build can't run without the libpq reference.
also it can't run on nixos naturally.

i try to build this project with nix's static build. and it's successfuly.
(reference: https://github.com/nh2/static-haskell-nix)
then we only need to copy the executable to any host, it can run on any linux platform.

this is the sample nix build script:
https://github.com/clojurians-org/nix-haskell-build/blob/master/postgrest/default.nix

@steve-chavez
Copy link
Member

steve-chavez commented May 21, 2019

@clojurians-org Thanks for the research on this one. Currently I build postgrest on NixOS with a custom shell.nix(see #1298).

A static build for Windows would be really great(see #365 (comment)), have you tried using nix there? We could try to integrate your script on appveyor(our CI for producing Windows binaries) as a first step.

@clojurians-org
Copy link
Author

clojurians-org commented May 22, 2019

i'm currently using nix static build(postgrest and postgres-websocket).
and it can be built on nixos and readhat system .
i didn't use windows os on my work.

@steve-chavez
Copy link
Member

Just confirmed the hard way that Docker is not deterministic. Our release pipeline failed with things like an outdated package url on centos6.

@clojurians-org Having a static binary released with nix is looking really good now. Do you know of a CI service that provides nix natively?

@steve-chavez
Copy link
Member

Found that Travis supports it https://docs.travis-ci.com/user/languages/nix/ and there's a docker image available for CircleCI https://hub.docker.com/r/nixorg/nix/.

@clojurians-org
Copy link
Author

you can reference hnix project:
https://github.com/haskell-nix/hnix/blob/master/.travis.yml

@steve-chavez
Copy link
Member

@clojurians-org Could you build a static binary for our latest commit dd86fe3 and share it here?(as tar.gz)

@clojurians-org
Copy link
Author

postgrest-v6.0.0-static.tar.gz

@clojurians-org
Copy link
Author

@steve-chavez
Copy link
Member

@clojurians-org Thank you so much! The static binary is working great!

I've attached it to our latest release https://github.com/PostgREST/postgrest/releases/tag/v6.0.0

@ggPeti
Copy link

ggPeti commented Jul 12, 2019

Hi there. Someone posted a shorter build definition which also doesn't use pkgsMusl, therefore is much quicker to build: NixOS/nixpkgs#37442 (comment)

@clojurians-org
Copy link
Author

clojurians-org commented Aug 1, 2019

for cache: cachix use static-haskell-nix

@steve-chavez
Copy link
Member

@clojurians-org Could you provide me the nix expression for our latest 6.0.1 version? I'd like to try building the binary myself.

@ggPeti
Copy link

ggPeti commented Aug 6, 2019

Is there anything wrong with @infinisil's version?

@steve-chavez
Copy link
Member

@ggPeti Nothing wrong. But that's not a statically linked binary.

@clojurians-org
Copy link
Author

i don't know whether the previous 6.0.0 nix script still working on 6.1.
i will test and build it on this weekend on my idle time.

@clojurians-org
Copy link
Author

@steve-chavez

the updated default.nix should work with some note.

i use jailbreak to loose jose's version dependency as the jose github don't have this version.
i fetch the latest jailbreak github repo, it still is v0.8.0.0, can't validated by cabal build.

https://github.com/clojurians-org/my-env/blob/master/nix.conf/postgrest-6.0.1/default.nix

@steve-chavez
Copy link
Member

@clojurians-org Thank you! I was able to build the static binary and published it to https://github.com/PostgREST/postgrest/releases/tag/v6.0.1.

Regarding jose, I've requested the addition of the git tag frasertweedale/hs-jose#83 (comment).

@steve-chavez
Copy link
Member

It would be great if someone could help me with a new nix expression for the latest version https://github.com/PostgREST/postgrest/releases/tag/v7.0.0. Or better yet, provide me the static binary so I can upload the asset.

@clojurians-org
Copy link
Author

clojurians-org commented Apr 4, 2020

it seems the nix cache has been outdated, the build is very slow.
i have no idea how to adjust to the new build method currently.
https://github.com/nh2/static-haskell-nix/tree/master/static-stack2nix-builder-example

@monacoremo
Copy link
Member

I contacted @nh2 for some insights on using his static-haskell-nix project and he generously offered to support us in getting static PostgREST builds to work. I'll open an issue on https://github.com/nh2/static-haskell-nix when I have a first draft for building a static 7.0.0

@monacoremo
Copy link
Member

monacoremo commented Apr 22, 2020

@monacoremo
Copy link
Member

@steve-chavez building those static executables from scratch takes ages, but we could get pretty quick incremental builds if we set up cachix in CI. With CACHIX_SIGNING_KEY configured as an environment variable in CircleCI, we could run something like this:

cachix use postgrest # Use the binary cache
nix-build | cachix push postgrest # Build and push new binaries

monacoremo added a commit to monacoremo/postgrest that referenced this issue Jul 17, 2021
* Include modifications to nixpkgs and static-haskell-nix as patches.

* use the patched static-haskell-nix version

* Add cachix postgrest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Related to CI setup
Development

No branches or pull requests

4 participants