File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 6262 { name = "postgresql-12" ; postgresql = pkgs . postgresql_12 . withPackages ( p : [ p . postgis p . pg_safeupdate ] ) ; }
6363 ] ;
6464
65+ haskellPackages = pkgs . haskell . packages . "${ compiler } " ;
66+
6567 # Dynamic derivation for PostgREST
66- postgrest = pkgs . lib . pipe ( pkgs . haskell . packages . " ${ compiler } " . callCabal2nix name src { } ) [
68+ postgrest = pkgs . lib . pipe ( haskellPackages . callCabal2nix name src { } ) [
6769 # To allow ghc-datasize to be used.
6870 lib . disableLibraryProfiling
6971 # We are never going to use dynamic haskell libraries anyway. "Dynamic" refers to how
8486
8587 # Derivation for the PostgREST Haskell package, including the executable,
8688 # libraries and documentation. We disable running the test suite on Nix
87- # builds, as they require a database to be set up.
88- postgrestPackage =
89- lib . dontCheck postgrest ;
89+ # builds, as they require a database to be set up. We split the binary
90+ # into a separate output, so that the default distribution via flake.nix
91+ # has a much smaller closure size.
92+ postgrestPackage = pkgs . lib . pipe postgrest [
93+ lib . dontCheck
94+ lib . enableSeparateBinOutput
95+ ] ;
9096
9197 # Profiled dynamic executable.
9298 postgrestProfiled = pkgs . lib . pipe postgrestPackage [
Original file line number Diff line number Diff line change 3333 in
3434 {
3535 packages = genSystems ( attrs : {
36- default = attrs . postgrestPackage ;
37- profiled = attrs . postgrestProfiled ;
36+ default = attrs . postgrestPackage . bin ;
37+ profiled = attrs . postgrestProfiled . bin ;
3838 } // nixpkgs . lib . optionalAttrs ( attrs ? postgrestStatic ) {
3939 static = attrs . postgrestStatic ;
4040 } ) ;
4141
4242 apps = genSystems ( attrs : {
4343 default = {
4444 type = "app" ;
45- program = "${ attrs . postgrestStatic or attrs . postgrestPackage } /bin/postgrest" ;
45+ program = "${ attrs . postgrestStatic or attrs . postgrestPackage . bin } /bin/postgrest" ;
4646 meta . description = "REST API for any Postgres database" ;
4747 } ;
4848 } ) ;
Original file line number Diff line number Diff line change @@ -351,12 +351,13 @@ let
351351 rm -f result
352352 if [ -z "'' ${PGRST_BUILD_CABAL:-}" ]; then
353353 echo -n "Building postgrest (nix)... "
354- nix-build -A postgrestPackage > "$tmpdir"/build.log 2>&1 || {
354+ # Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet.
355+ nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || {
355356 echo "failed, output:"
356357 cat "$tmpdir"/build.log
357358 exit 1
358359 }
359- PGRST_CMD=./result/bin/postgrest
360+ PGRST_CMD=$(echo ./result* /bin/postgrest)
360361 else
361362 echo -n "Building postgrest (cabal)... "
362363 postgrest-build
You can’t perform that action at this time.
0 commit comments