-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Fully static Haskell executables - overview issue #43795
Copy link
Copy link
Open
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.6.topic: haskellGeneral-purpose, statically typed, purely functional programming languageGeneral-purpose, statically typed, purely functional programming language
Metadata
Metadata
Assignees
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.6.topic: haskellGeneral-purpose, statically typed, purely functional programming languageGeneral-purpose, statically typed, purely functional programming language
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Enhancements
If you just want to build static Haskell executables right now, follow these instructions.
This issue collects/links all issues and ongoing work to make fully-static building of Haskell executables an excellently-working feature in nixpkgs.
I will update here regularly the progress we are making, and sub-goals we encounter on the way that need to be fulfilled to tick off the parent goal.
Obviously contributions to this list are welcome.
stackbased projects with their ownresolvershould be really easystackbased example should be added (here)AllMost Haskell executables in nixpkgs succeed to build staticallysurveydirectory of https://github.com/nh2/static-haskell-nixnixpkgsStackageconfiguration-hackage2nix.yamlto be able to filter for Stackage packages (thanks @domenkozar for the tip)stackstackbuilds withcrossSystem = { config = "x86_64-unknown-linux-musl"; };stackbuilds withpkgsMuslstackbuilds with its own Stackage snapshot viastack2nixstack1.9 official release uses this toolchain for its static buildintray-web-server(which includes, amongst others,servant) (CC @NorfairKing)dhall(CC @Gabriel439)cachix(CC @domenkozar)xmonadlibgmp.so.3errorlibgmperror is gone since Fully static Haskell executables - overview issue #43795 (comment)pandoc(CC @jgm)hsluatest case segfault might mean some functionality will crashdarcslibcurlwhich itself has many dependencies, and had to fix a cabal issue for it, but it's working now.aurastatic-haskell-nixCI build that tracks nixpkgsmasterto find breakage early (done)crossSystem = { config = "x86_64-unknown-linux-musl"; };support is working (done by @dtzWill)pkgsMuslsupport has landed in nixpkgs master (done by @dtzWill)masterArgument list too longwhen linkingCabal--enable-executable-staticfeature is available in nixpkgshaskellPackageswhere all exes are statically linkedCabalrelease is available that includes itCabal--ld-optionGHC passthrough feature is available in nixpkgs.afiles) only at the linker stageCabalrelease is available that includes it.afiles)ncurses.aandtinfofix has been merged tostaging(done by (@shlevy).aandtinfofix has been merged tomaster(this is a mass-rebuild PR) (merged)staginghas landed inmaster(only.afix, nottinfopart, because it's not a mass-rebuild PRpkgsStatic- a fully static overlaypkgsStaticto nixpkgsmaster(@matthewbauer)static-haskell-nixon top of it (move system dependency overrides that add static libs there)pkgsStaticcan be used as a base.pkgsStatic(Provide middle-ground overlay between pkgsMusl and pkgsStatic #61575), then drop commitpkgsStatic: Don't disable .so files.from forked nixpkgsmastercurl-configwhen cross-compiling. #61552pkgsStatic: Don't disable static on curl for git #66416pkgsStatic: Add libffi override #66417callPackage#66503--disable-static#66759static-haskell-nix's Haskell functionality over as well-ffunction-sectionscan make final executables even smaller (results)integer-simpleinstead ofinteger-gmp, aslibgmpis the biggest LGPL dependency of all Haskell programs (see here)integer-opensslto be ready for use (CC @ch1bo)Why is static linking desirable?
Static linking means your executable depends on as few things running on the target system as possible.
For Linux, it means that an executable you build will work on any Linux distribution, with essentially infinite forwards-compatibility (because Linux in general does not change its system call interface).
Statically linked executables do not depend on the target system's
libc.Statically linked executable are incredibly easy to deploy (many Go executables are statically linked, which gave them the reputation of being easy to deploy in the devops world).
Statically linked executables can start faster than dynamically linked ones where dynamic linking has to be performed at startup (of course the startup time depends on the number of libraries to link and the amount of symbols contained within).
Statically linked executables are smaller (up to 4x in our mesurements), mostly because GHC's
-split-sectionshas way more effects with them (for unknown reason for now).Who is working on or contributing to this
Feel free to add yourself!