diff --git a/nix/libpq.nix b/nix/libpq.nix index efe3fb9c7..150029462 100644 --- a/nix/libpq.nix +++ b/nix/libpq.nix @@ -19,6 +19,10 @@ stdenv.mkDerivation { pname = "libpq"; inherit (postgresql) src version patches; + __structuredAttrs = true; + env.CFLAGS = "-fdata-sections -ffunction-sections" + + (if stdenv.cc.isClang then " -flto" else " -fmerge-constants -Wl,--gc-sections"); + configureFlags = [ "--without-gssapi" "--without-icu" diff --git a/nix/static.nix b/nix/static.nix index b3cada94c..0e626d141 100644 --- a/nix/static.nix +++ b/nix/static.nix @@ -5,11 +5,7 @@ }: let # This builds a static PostgREST executable based on pkgsStatic. - # pkgsStatic is based on musl, so is a kind of cross-compilation. - # We still make this explicit here via pkgsCross, because we need - # to get postgresql/libpq for musl, too. - pkgsCross = pkgs.pkgsCross.musl64; - inherit (pkgsCross) pkgsStatic; + inherit (pkgs) pkgsStatic; inherit (pkgsStatic.haskell) lib; packagesStatic = @@ -33,7 +29,7 @@ let configureFlags = [ "-fuse-pkg-config" ]; # postgresql doesn't build in the fully static overlay - but the default # derivation is built with static libraries anyway. - libraryPkgconfigDepends = [ pkgsCross.libpq ]; + libraryPkgconfigDepends = [ pkgsStatic.libpq ]; librarySystemDepends = [ ]; }).overrideAttrs (_: prevAttrs: { buildInputs = prevAttrs.buildInputs ++ [ pkgsStatic.openssl ];