Skip to content

Commit b06f897

Browse files
committed
README: Improvements
1 parent 9fea811 commit b06f897

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Diff for: README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,25 @@
33
With this repository you can easily build most Haskell programs into fully static Linux executables.
44

55
* results are fully static executables (`ldd` says `not a dynamic executable`)
6-
* to make that possible, it and all dependencies (including ghc) are built against [`musl`](https://www.musl-libc.org/) instead of glibc
6+
* to make that possible, each exe and all dependencies (including ghc) are built against [`musl`](https://www.musl-libc.org/) instead of glibc
77

88
## History
99

1010
`glibc` encourages dynamic linking to the extent that correct functionality under static linking is somewhere between difficult and bug-ridden.
1111
For this reason, static linking, despite its many advantages (details [here](https://github.com/NixOS/nixpkgs/issues/43795)) has become less and less common.
1212

13-
Due to GHC's dependency on a libc, and many libraries depending on C libraries for which Linux distributions often do not include static library archive files, this situation has resulted in Haskell programs being extremely hard to produce for the common Haskeller, even though the language is generally well-suited for static linking.
13+
Due to GHC's dependency on a libc, and many libraries depending on C libraries for which Linux distributions often do not include static library archive files, this situation has resulted in fully static Haskell programs being extremely hard to produce for the common Haskeller, even though the language is generally well-suited for static linking.
1414

15-
This project set out to solve this.
15+
This project solves this.
1616

1717
It was inspired by a [blog post by Vaibhav Sagar](https://vaibhavsagar.com/blog/2018/01/03/static-haskell-nix/),
1818
and a [comment by Will Dietz](https://github.com/NixOS/nixpkgs/pull/37598#issuecomment-375117019) about musl.
1919

20+
Work on this so far was sponsored largely by my free time, [FP Complete](https://haskell.fpcomplete.com/) and their clients, and the contributors mentioned [here](https://github.com/NixOS/nixpkgs/issues/43795#issue-342546855).
21+
2022
By now we have a nixpkgs issue on [Fully static Haskell executables](https://github.com/NixOS/nixpkgs/issues/43795) (progress on which is currently this repo, with plans to later merge it into nixpkgs), and [a merged nixpkgs overlay for static nixpkgs in general](https://github.com/NixOS/nixpkgs/pull/48803).
2123

22-
## Building a minimal example
24+
## Building a minimal example (don't use this in practice)
2325

2426
`default.nix` builds an example executable (originally from https://github.com/vaibhavsagar/experiments). Run:
2527

@@ -30,7 +32,7 @@ NIX_PATH=nixpkgs=nixpkgs nix-build --no-link
3032
This prints a path that contains the fully linked static executable in the `bin` subdirectory.
3133

3234
This example is so that you get the general idea.
33-
In practice, you probably want to use the approach in the "Building arbitrary packages" section below.
35+
In practice, you probably want to use one of the approaches from the "Building arbitrary packages" or "Building stack projects" sections below.
3436

3537
## Binary caches for faster building (optional)
3638

@@ -49,8 +51,6 @@ Note that you may not get cached results if you use a different `nix` version th
4951

5052
## Building arbitrary packages
5153

52-
The [`static-stack`](./static-stack) directory shows how to build a fully static `stack` executable (a Haskell package with many dependencies), and makes it reasonably easy to build other packages as well.
53-
5454
The [`survey`](./survey) directory maintains a select set of Haskell executables that are known and not known to work with this approach; contributions are welcome to grow the set of working executables.
5555
Run for example:
5656

@@ -63,3 +63,13 @@ There are multiple package sets available in the survey (select via `-A`):
6363
* `working` -- build all exes known to be working
6464
* `notWorking` -- build all exes known to be not working (help welcome to make them work)
6565
* `haskellPackages.somePackage` -- build a specific package from our overridden package set
66+
67+
If you are a nix user, you can easily `import` this functionality and add an override to add your own packages.
68+
69+
## Building `stack` projects
70+
71+
The [`static-stack2nix-builder-example`](./static-stack2nix-builder-example) directory shows how to build any `stack`-based project statically.
72+
73+
Another example of this is the the official static build of `stack` itself.
74+
See the [`static-stack`](./static-stack) directory for how that's done.
75+
`stack` is a big package with many dependencies, demonstrating that this works also for large projects.

Diff for: static-stack2nix-builder-example/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Example stack-based project that shows how to use `static-stack2nix-builder`.
44

55
## Usage in your project
66

7-
Copy the `default.nix` into your project, and adjust it as needed.
7+
Copy the [`default.nix`](./default.nix) into your project, and adjust it as needed.
88

99
It has instructions for running inside.

0 commit comments

Comments
 (0)