@hackage stack2nix0.1.2.0
Convert stack.yaml files into Nix build instructions.
Categories
License
MIT
Maintainer
jacob.mitchell@iohk.io
Links
Versions
Installation
Dependencies (16)
- Cabal >=1.24.2 && <1.25
- Glob >=0.7.14 && <0.8
- SafeSemaphore >=0.10.1 && <0.11
- async >=2.1.1.1 && <2.2
- base >=4.9 && <4.10
- bytestring >=0.10.8.1 && <0.11 Show all…
Dependents (0)
stack2nix
About
stack2nix automates conversion from Stack configuration file to Nix expressions.
stack2nix high-level workflow:
- invoke
stack list-dependenciesto 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
- Install nix.
- Clone this repo.
- Run
stack installto install. - Ensure
cabal2nixv2.2.1 or higher andstack2nixare in your$PATH.
Virtual Machine
- Install VirtualBox and Vagrant.
- Clone this repo.
- Run
./scripts/vagrant.shand take a coffee break. - 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.