3[](https://travis-ci.org/typeable/stackage2nix)
5`stackage2nix` converts a Stack file into a Nix Haskell packages set.
7# Create build derivation from stack.yaml
9## Generate targets from stack.yaml only
12stack exec -- stackage2nix .
15Command creates file `default.nix` which overrides `haskell.packages.stackage`
16packages set. You should use
17[typeable/nixpkgs-stackage](https://github.com/typeable/nixpkgs-stackage) overlay that
18adds LTS Stackage packages to Nixpkgs.
20Build package with overlay installed:
23nix-build -A stackage2nix
26## Generate Stackage packages for the build
28If you don't want to use Stackage overlay, stackage2nix can generate required
29packages with `--with-stackage-closure` flag.
32stack exec -- stackage2nix \
33 --all-cabal-hashes /path/to/commercialhaskell/all-cabal-hashes \
34 --lts-haskell /path/to/fpco/lts-haskell \
35 --with-stackage-closure \
39To 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)
42checked out to `hackage` branch and
43[fpco/lts-haskell](https://github.com/fpco/lts-haskell) respectively.
45### stackage2nix wrapper
47You can use stackage2nix wrapper from `nix` directory that adds required flags:
50nix-env -i -f ./nix/stackage2nix
51stackage2nix --with-stackage-closure ./stack.yaml
54This command will produce `packages.nix` and `configuration-packages.nix`
55Stackage packages and its override in `default.nix`
57## Generate full Stackage
59`--with-stackage` parameter generates full Stackage LTS in addition to the
60targets from `stack.yaml`
63nix-env -i -f ./nix/stackage2nix
64stackage2nix --with-stackage ./stack.yaml
67## Generate Stackage from LTS resolver
69You can also generate only Stackage packages set from the resolver:
72nix-env -i -f ./nix/stackage2nix
73stackage2nix --resolver lts-10.0
76This command will produce Stackage packages `packages.nix`, packages config
77`configuration-packages.nix` and a Haskell packages set `default.nix`.
79## Runtime dependencies
81- `nix-env` is required to be on PATH by the
82 [distribution-nixpkgs](https://hackage.haskell.org/package/distribution-nixpkgs)
84- `nix-prefetch-scripts` is required on PATH if you have git dependencies in
87## Override result derivation
89Complex projects may require some extra customization.
90Snippet `override.nix` below shows a minimal example of how to apply additional
91overrides on top of Haskell packages set produced by `stackage2nix`.
94with import <nixpkgs> {};
96let haskellPackages = import ./. {};
97in haskellPackages.override {
98 overrides = self: super: {
99 stackage2nix = disableSharedExecutables super.stackage2nix;
105nix-build -A stackage2nix override.nix
108For more complex overrides and detailed information on how to work with Haskell packages in Nix, see Nixpkgs manual [User’s Guide to the Haskell Infrastructure](http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure)
112Integration tests that build stackage2nix form different yaml configs:
115STACKAGE_REPO=<path/to/stackage/repo> \
116ALL_CABAL_HASHES=<path/to/all-cabal-hashes/repo> \
117STACK_FILE=stack-ghc-7103.yaml \
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list