@@ -3,73 +3,76 @@
3[](https://travis-ci.org/typeable/stackage2nix)
3[](https://travis-ci.org/typeable/stackage2nix)
5`stackage2nix` converts a Stack file into a Nix Haskell packages set.
5`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.
8−## Install
7+# Create Nix build from stack.yaml
10−You can install `stackage2nix` from the Nix expression:
9+## Generate targets from stack.yaml only
13−nix-env -i -f ./nix/stackage2nix
12+stackage2nix .
16−It provides pre-configured wrapper around the raw executable with runtime
15+Command creates file `default.nix` which overrides `haskell.packages.stackage`
17−`PATH` and all auxiliary flags set up.
16+packages set. Currently Nixpkgs maintains only Hackage packages, but you can
18−
17+use [4e6/nixpkgs-stackage](https://github.com/4e6/nixpkgs-stackage) overlay that
19−## Build project
18+adds LTS Stackage packages.
21−Generate derivations from `stack.yaml` config using Nix wrapper:
20+Build package with overlay installed:
24−stackage2nix ./stack.yaml
23+nix-build -A stackage2nix
27−if you're using the raw executable, you should supply additional flags. See
26+## Generate Stackage packages for the build
28−section 'Flags' below for details.
30−This command will result in a Haskell packages set, similar to
28+If you don't want to use Stackage overlay, stackage2nix can generate required
31−`pkgs.haskell.packages.<compiler>`, containing only packages that are required
29+packages with `--with-stackage-closure` flag.
32−to build targets listed in `stackage.yaml`. To build a package run:
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
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.
40−Generate complete Stackage packages set from resolver:
45+You can use stackage2nix wrapper from `nix` directory that adds required flags:
43−stackage2nix --resolver lts-9.0
48+nix-env -i -f ./nix/stackage2nix
49+stackage2nix --with-stackage ./stack.yaml
52+This command will produce `packages.nix` and `configuration-packages.nix`
53+Stackage packages and its override in `default.nix`
46−## Flags
55+## Generate full Stackage
57+`--with-stackage` parameter generates full Stackage lts in addition to the
58+targets from `stack.yaml`
49−stackage2nix \
61+nix-env -i -f ./nix/stackage2nix
50− --lts-haskell "$LTS_HASKELL_REPO" \
62+stackage2nix --with-stackage ./stack.yaml
51− --all-cabal-hashes "$ALL_CABAL_HASHES_REPO" \
55−`stackage2nix` has three required arguments:
65+## Generate Stackage from LTS resolver
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
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−A particular package from result Haskell packages set can be built with:
67+You can also generate only Stackage packages from the resolver:
68−nix-build -A <package-name>
70+nix-env -i -f ./nix/stackage2nix
71+stackage2nix --resolver lts-10.0
71−See also the [blog post](https://blog.typeable.io/posts/2017-08-24-stackage2nix.html)
74+This command will produce Stackage packages `packages.nix`, packages config
72−about history and motivation behind the project.
75+`configuration-packages.nix` and a Nix Haskell packages set `default.nix`.
74## Runtime dependencies
77## Runtime dependencies
@@ -87,7 +90,7 @@ overrides on top of Haskell packages set produced by `stackage2nix`.
89with import <nixpkgs> {};
92with import <nixpkgs> {};
90−with pkgs.haskell.lib;
93+with haskell.lib;
91let haskellPackages = import ./. {};
94let haskellPackages = import ./. {};
92in haskellPackages.override {
95in haskellPackages.override {
93 overrides = self: super: {
96 overrides = self: super: {
@@ -104,7 +107,7 @@ For more complex overrides and detailed information on how to work with Haskell
107−Integration tests that build stackage2nix form different stack configs:
110+Integration tests that build stackage2nix form different yaml configs:
110STACKAGE_REPO=<path/to/stackage/repo> \
113STACKAGE_REPO=<path/to/stackage/repo> \