Skip to content

Latest commit

 

History

History
 
 

static-stack

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Fully statically linked stack

This builds a fully statically linked stack executable that should work on any 64-bit Linux distribution.

It uses nix to build everything, including ghc, against the musl libc.

Building

$(nix-build --no-link -A fullBuildScript --argstr stackDir /absolute/path/to/stack/source)

We use the $(nix-build ...) script approach in order to pin the version of nix itself for reproducibility, and because the call to stack2nix needs Internet access and thus has to run outside of the nix build sandbox.

If you get an error such as:

stack2nix: user error (No such package foo-1.2.3.4 in the cabal database. Did you run cabal update?)

then update the hackageSnapshot date in default.nix to a date that includes the package and version.

Temporarily: Use stack-lts-12.yaml

See #81: Stack's main stack.yaml uses GHC 8.2.2, which is no longer in recent nixpkgs.

If you get an error mentioning error: attribute 'ghc822' in selection path 'haskell.compiler.ghc822' not found, then build stack the same way as our CI does it.

Alternatively you can use an older version of static-haskell-nix that pins an older version of nixpkgs that still has ghc822.

This issue will likely go away very soon given that stack is as-of-writing upgrading stack.yaml to a newer LTS.

Binary caches for faster building (optional)

You can use the caches described in the top-level README for faster building.

stack binaries

Static stack binaries I built this way, for download: