typeable/stackage2nix

Name: stackage2nix

Owner: TypeableIO

Description: Generate Nix build instructions from a Stack file

Created: 2017-05-21 18:07:58.0

Updated: 2018-04-23 14:17:19.0

Pushed: 2018-04-23 14:19:11.0

Homepage: null

Size: 202

Language: Nix

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

stackage2nix

Build Status

stackage2nix converts a Stack file into a Nix Haskell packages set.

Create build derivation from stack.yaml

Generate targets from stack.yaml only
k exec -- stackage2nix .

Command creates file default.nix which overrides haskell.packages.stackage packages set. You should use typeable/nixpkgs-stackage overlay that adds LTS Stackage packages to Nixpkgs.

Build package with overlay installed:

build -A stackage2nix
Generate Stackage packages for the build

If you don't want to use Stackage overlay, stackage2nix can generate required packages with --with-stackage-closure flag.

k exec -- stackage2nix \
all-cabal-hashes /path/to/commercialhaskell/all-cabal-hashes \
lts-haskell /path/to/fpco/lts-haskell \
with-stackage-closure \
stack.yaml

To generate Stackage packages, you should supply additional --all-cabal-hashes and --lts-haskell flags that points to commercialhaskell/all-cabal-hashes checked out to hackage branch and fpco/lts-haskell respectively.

stackage2nix wrapper

You can use stackage2nix wrapper from nix directory that adds required flags:

env -i -f ./nix/stackage2nix
kage2nix --with-stackage-closure ./stack.yaml

This command will produce packages.nix and configuration-packages.nix Stackage packages and its override in default.nix

Generate full Stackage

--with-stackage parameter generates full Stackage LTS in addition to the targets from stack.yaml

env -i -f ./nix/stackage2nix
kage2nix --with-stackage ./stack.yaml
Generate Stackage from LTS resolver

You can also generate only Stackage packages set from the resolver:

env -i -f ./nix/stackage2nix
kage2nix --resolver lts-10.0

This command will produce Stackage packages packages.nix, packages config configuration-packages.nix and a Haskell packages set default.nix.

Runtime dependencies
Override result derivation

Complex projects may require some extra customization. Snippet override.nix below shows a minimal example of how to apply additional overrides on top of Haskell packages set produced by stackage2nix.

 import <nixpkgs> {};
 haskell.lib;
haskellPackages = import ./. {};
askellPackages.override {
errides = self: super: {
stackage2nix = disableSharedExecutables super.stackage2nix;



build -A stackage2nix override.nix

For 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

Tests

Integration tests that build stackage2nix form different yaml configs:

KAGE_REPO=<path/to/stackage/repo> \
CABAL_HASHES=<path/to/all-cabal-hashes/repo> \
K_FILE=stack-ghc-7103.yaml \
-stackage2nix

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.