Add some comments regarding the static build options

This commit is contained in:
Paul Brinkmeier 2025-07-13 13:37:08 +02:00
parent 4bbc31f41b
commit 58f5a861f3

View File

@ -26,23 +26,29 @@
# And some build configuration.
# See https://nixos.org/manual/nixpkgs/unstable/#haskell-packaging-helpers.
[
# Configurable static build. Set cabal options...
compose.disableSharedExecutables
compose.disableSharedLibraries
# ... and link required static libraries.
(compose.appendConfigureFlags [
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-L${pkgs.gmp6.override { withStatic = true; }}/lib"
"--ghc-option=-optl=-L${pkgs.zlib.static}/lib"
"--ghc-option=-optl=-L${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
])
# Remove warp which pulls GHC into the runtime deps for some reason.
# Remove all references to the Nix store from the executable.
# This is important because Nix uses the references for calculating
# what needs to be in the Docker container.
# FIXME: Using static linking, these references shouldn't even still be there.
# Can we somehow make GHC stop emitting them?
(compose.overrideCabal (drv: {
postInstall = ''
remove-references-to -t ${pkgs.haskellPackages.warp} $out/bin/utoy
${pkgs.nukeReferences}/bin/nuke-refs $out/bin/utoy
'';
}))
# Return only the bin folder to curb image size
# Return only the bin folder to curb image size.
compose.justStaticExecutables
];
in {