Compare commits

...

2 Commits

Author SHA1 Message Date
Paul Brinkmeier
58f5a861f3 Add some comments regarding the static build options 2025-07-13 13:37:08 +02:00
Paul Brinkmeier
4bbc31f41b Build static binary 2025-07-13 13:23:18 +02:00

View File

@ -26,13 +26,29 @@
# And some build configuration.
# See https://nixos.org/manual/nixpkgs/unstable/#haskell-packaging-helpers.
[
# Remove warp which pulls GHC into the runtime deps for some reason.
# 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"
"--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 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 {