@@ -3,73 +3,76 @@
33[](https://travis-ci.org/typeable/stackage2nix)
44
55`stackage2nix` converts a Stack file into a Nix Haskell packages set.
6−It creates LTS Stackage packages set, and applies appropriate overrides on top of it.
76
8−## Install
7+# Create Nix build from stack.yaml
98
10−You can install `stackage2nix` from the Nix expression:
9+## Generate targets from stack.yaml only
1110
1211```
13−nix-env -i -f ./nix/stackage2nix
12+stackage2nix .
1413```
1514
16−It provides pre-configured wrapper around the raw executable with runtime
17−`PATH` and all auxiliary flags set up.
18−
19−## Build project
15+Command creates file `default.nix` which overrides `haskell.packages.stackage`
16+packages set. Currently Nixpkgs maintains only Hackage packages, but you can
17+use [4e6/nixpkgs-stackage](https://github.com/4e6/nixpkgs-stackage) overlay that
18+adds LTS Stackage packages.
2019
21−Generate derivations from `stack.yaml` config using Nix wrapper:
20+Build package with overlay installed:
2221
23−``` bash
24−stackage2nix ./stack.yaml
22+```
23+nix-build -A stackage2nix
2524```
2625
27−if you're using the raw executable, you should supply additional flags. See
28−section 'Flags' below for details.
26+## Generate Stackage packages for the build
2927
30−This command will result in a Haskell packages set, similar to
31−`pkgs.haskell.packages.<compiler>`, containing only packages that are required
32−to build targets listed in `stackage.yaml`. To build a package run:
28+If you don't want to use Stackage overlay, stackage2nix can generate required
29+packages with `--with-stackage-closure` flag.
3330
3431``` bash
35−nix-build -A my-package
32+stackage2nix \
33+ --all-cabal-hashes /path/to/commercialhaskell/all-cabal-hashes \
34+ --lts-haskell /path/to/fpco/lts-haskell \
35+ --with-stackage-closure
36+ ./stack.yaml
3637```
3738
38−## Build stackage
39+To generate Stackage packages, you should supply additional
40+`--all-cabal-hashes` and `--lts-haskell` flags that points to
41+[commercialhaskell/all-cabal-hashes](https://github.com/commercialhaskell)
42+checked out to `hackage` branch and
43+[fpco/lts-haskell](https://github.com/fpco/lts-haskell) respectively.
3944
40−Generate complete Stackage packages set from resolver:
45+You can use stackage2nix wrapper from `nix` directory that adds required flags:
4146
42−``` bash
43−stackage2nix --resolver lts-9.0
4447```
48+nix-env -i -f ./nix/stackage2nix
49+stackage2nix --with-stackage ./stack.yaml
50+```
51+
52+This command will produce `packages.nix` and `configuration-packages.nix`
53+Stackage packages and its override in `default.nix`
4554
46−## Flags
55+## Generate full Stackage
56+
57+`--with-stackage` parameter generates full Stackage lts in addition to the
58+targets from `stack.yaml`
4759
4860```
49−stackage2nix \
50− --lts-haskell "$LTS_HASKELL_REPO" \
51− --all-cabal-hashes "$ALL_CABAL_HASHES_REPO" \
52− .
61+nix-env -i -f ./nix/stackage2nix
62+stackage2nix --with-stackage ./stack.yaml
5363```
5464
55−`stackage2nix` has three required arguments:
56−- `--lts-haskell` - path to [fpco/lts-haskell](https://github.com/fpco/lts-haskell)
57−- `--all-cabal-hashes` - path to [commercialhaskell/all-cabal-hashes](https://github.com/commercialhaskell/all-cabal-hashes) checked out to `hackage` branch
58−- `.` - path to stack.yaml file or directory
59−
60−Produced Nix derivation split on following files:
61−- packages.nix - Base Stackage packages set
62−- configuration-packages.nix - Compiler configuration
63−- default.nix - Final Haskell packages set with all overrides applied
65+## Generate Stackage from LTS resolver
6466
65−A particular package from result Haskell packages set can be built with:
67+You can also generate only Stackage packages from the resolver:
6668
6769```
68−nix-build -A <package-name>
70+nix-env -i -f ./nix/stackage2nix
71+stackage2nix --resolver lts-10.0
6972```
7073
71−See also the [blog post](https://blog.typeable.io/posts/2017-08-24-stackage2nix.html)
72−about history and motivation behind the project.
74+This command will produce Stackage packages `packages.nix`, packages config
75+`configuration-packages.nix` and a Nix Haskell packages set `default.nix`.
7376
7477## Runtime dependencies
7578
@@ -87,7 +90,7 @@ overrides on top of Haskell packages set produced by `stackage2nix`.
8790
8891```
8992with import <nixpkgs> {};
90−with pkgs.haskell.lib;
93+with haskell.lib;
9194let haskellPackages = import ./. {};
9295in haskellPackages.override {
9396 overrides = self: super: {
@@ -104,7 +107,7 @@ For more complex overrides and detailed information on how to work with Haskell
104107
105108## Tests
106109
107−Integration tests that build stackage2nix form different stack configs:
110+Integration tests that build stackage2nix form different yaml configs:
108111
109112```
110113STACKAGE_REPO=<path/to/stackage/repo> \