stack2nix

Convert stack.yaml files into Nix build instructions.

Latest on Hackage:0.2

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

MIT licensed by Jacob Mitchell

stack2nix

Build Status

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 three 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

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

Virtual Machine

  1. Install VirtualBox and Vagrant.
  2. Clone this repo.
  3. Run ./scripts/vagrant.sh and take a coffee break.
  4. If there are no errors, log into the VM: vagrant ssh.

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 (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.

comments powered byDisqus