stack2nix: Convert stack.yaml files into Nix build instructions.

[ distribution, library, mit, nix, program ] [ Propose Tags ]

Convert stack.yaml files into Nix build instructions.

[Skip to Readme]
Versions [faq],,, 0.2, 0.2.1, 0.2.2, 0.2.3
Change log
Dependencies async (>= && <2.3), base (>=4.9 && <4.12), Cabal (>= && <2.3), cabal2nix (>=2.10), containers (>= && <0.6), directory (==1.3.*), distribution-nixpkgs (==1.1.*), filepath (>= && <1.5), hackage-db, language-nix, lens, optparse-applicative (>=0.13.2 && <0.15), path, pretty, process (>=1.4.3 && <1.7), regex-pcre (>=0.94.4 && <0.95), SafeSemaphore (>=0.10.1 && <0.11), stack (>=1.5.1), stack2nix, temporary (>= && <1.4), text (>= && <1.3), time [details]
License MIT
Author Jacob Mitchell
Revised Revision 1 made by domenkozar at Tue Sep 4 15:14:06 UTC 2018
Category Distribution, Nix
Source repo head: git clone
Uploaded by domenkozar at Tue Jul 24 22:13:04 UTC 2018
Distributions LTSHaskell:0.2.3, NixOS:0.2.3, Stackage:0.2.3
Executables stack2nix
Downloads 1483 total (72 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2018-07-24 [all 1 reports]


[Index] [Quick Jump]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Readme for stack2nix-0.2

[back to package description]


Build Status


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


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.


  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/ and take a coffee break.
  4. If there are no errors, log into the VM: vagrant ssh.


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 > demo.nix
    $ nix-build -A pandoc demo.nix


Run ./scripts/ to build and test.