The stack2nix package

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

Convert stack.yaml files into Nix build instructions.


[Skip to Readme]

Properties

Versions 0.1.1.0, 0.1.2.0, 0.1.3.0
Dependencies async (>=2.1.1.1 && <2.2), base (==4.9.*), bytestring (>=0.10.8.1 && <0.11), Cabal (>=1.24.2 && <1.25), containers (>=0.5.7.1 && <0.6), data-fix (==0.0.4), directory (==1.3.*), filepath (>=1.4.1.1 && <1.5), Glob (>=0.7.14 && <0.8), hnix (>=0.3.4 && <0.4), monad-parallel (>=0.7.2.2 && <0.8), optparse-applicative (>=0.13.2 && <0.14), process (>=1.4.3 && <1.5), SafeSemaphore (>=0.10.1 && <0.11), stack2nix, temporary (>=1.2.0.4 && <1.3), text (>=1.2.2.1 && <1.3), yaml (>=0.8.22.1 && <0.9) [details]
License MIT
Author Jacob Mitchell
Maintainer jacob.mitchell@iohk.io
Category Distribution, Nix
Source repository head: git clone https://github.com/input-output-hk/stack2nix.git
Uploaded Tue Jun 27 14:53:28 UTC 2017 by jmitchell_iohk
Distributions NixOS:0.1.3.0
Executables stack2nix
Downloads 163 total (11 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-06-27 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for stack2nix-0.1.3.0

[back to package description]

stack2nix

Build Status

About

stack2nix automates conversion from Stack configuration file to Nix expressions.

stack2nix high-level workflow:

  • invoke stack list-dependencies 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 is to install stack2nix and its dependencies on your machine directly, and the second is to use the supported virtual machine configuration.

If there are difficulties please file an issue. Generally the virtual machine approach should be more reliable.

Native Environment

  1. Install nix.
  2. Clone this repo.
  3. Run stack install to install.
  4. Ensure cabal2nix v2.2.1 or higher and stack2nix are in your $PATH.

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 depend on a somewhat recent upstream change to nixpkgs. If nix-env or nix-build fails with an error mentioning initialPackages, try setting the NIX_PATH environment variable: NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/21a8239452adae3a4717772f4e490575586b2755.tar.gz.

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

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

Testing

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