stack2nix

Convert stack.yaml files into Nix build instructions.

Version on this page:0.2.2@rev:1
LTS Haskell 13.30:0.2.3
Stackage Nightly 2019-06-21:0.2.3
Latest on Hackage:0.2.3

See all snapshots stack2nix appears in

MIT licensed by IOHK DevOps
Maintained by [email protected]
This version can be pinned in stack with:stack2nix-0.2.2@sha256:8fc1b3fd5c70bd94799538c28b77cf71a62125841582947aa39750fcfe6db9e7,2729

Module documentation for 0.2.2

stack2nix

Build Status Hackage

About

stack2nix automates conversion from Stack configuration file to Nix expressions. The purpose is to map stack.yaml one-to-one into Nix expressions.

stack2nix high-level workflow:

  • Generate stackage snapshot to determine complete fixed version list of packages based on resolver
  • apply any additional configuration (local packages, extra dependencies, etc) from stack.yaml
  • generate complete list of dependencies to Nix expressions, replacing upstream hackage-packages.nix

Installation

There are two options. The first - using Nix is recommended. If there are difficulties please file an issue.

Nix (recommended)

  1. Install Nix.
  2. Clone this repo.
  3. Run nix-build to build.

Stack + Nix

  1. Install Nix.
  2. Clone this repo.
  3. Run stack install --nix to install.

Usage

Nix expressions generated by stack2nix require NixOS 17.09 or later.

Local Packages

Sometimes it’s convenient to build local Haskell packages. Assuming the current directory is a locally maintained fork of Pandoc:

    $ stack2nix . > default.nix
    $ nix-build -A pandoc

Remote Packages

Stack2nix can generate a nix expressions for Haskell packages hosted in git repositories.

    $ stack2nix --revision 242e2a064f6a32b22e1599bbfe72e64d7b6203b8 https://github.com/jgm/pandoc.git > demo.nix
    $ nix-build -A pandoc demo.nix

Testing

Run ./scripts/travis.sh to build and test.

Changes

Changelog

v0.2.2 (2019-01-17)

Bug fixes:

  • LTS-13 compatibility
  • Proper fix for bin-package-db #118
  • Add package flags #148
  • Upgrade stack to 1.9 #133

v0.2.1 (2018-09-04)

Bug fixes:

  • null bin-package-db for GHC 7.10 #118
  • Bump cabal2nix and remove upper bound #120
  • Parse mac operating system as osx or darwin #123
  • Don’t use src = ./. #121
  • Pass –compiler to calls to cabal2nix #115

v0.2 (2018-07-24)

Major changes:

  • Use full stackage snapshot instead of relying on the build plan #83
  • Get rid of hnix and rely on Derivation type from cabal2nix
  • Use nix to provision executables if missing #83
  • Use GHC version that belongs to the LTS #84
  • ghc-options in stack.yaml are now passed to generated Nix exprs #96
  • Support –bench #97

Other enhancements:

  • Support –platform to set targeting system generation #79
  • Use cabal2nix and stack as haskell libraries instead of relying on executable parsing #75
  • Add –verbose flag #78
  • Be able to pin down hackage snapshot #75
  • Optimize cabal2nix calls by reusing HackageDB #75
  • Rewrite tests in hspec to reduce dependencies #83
  • Make stack.yaml filename configurable #90
  • Add option to disable indentation #89
  • When cloning git, also checkout submodules #108

Bug fixes:

  • Be able to override GHC core packages #51
  • Cleanup concurrency #33
  • Add –haddock #38
  • Add –test #35
  • Support Stack subdirs #10
  • Correct version parsing #67
  • Silence git stdout output not to leak into Nix #91

v0.1.3.0 (2017-07-27)

Bug fixes:

  • Apply only Nix overrides without version fixes #26

v0.1.2.0 (2017-06-22)

Bug fixes:

  • Minor stack2nix.cabal improvements

v0.1.1.0 (2017-06-22)

Initial public release.