on bddc91f help sign in
haskell.nix/docs/user-guide-stack.md
60 lines 1.5 kB history raw
1# User Guide (stack project)
3Here we will look into how to generate the `pkgs.nix` file for a
4`stack.yaml` project. For the full integration please see the [User
5Guide](/user-guide)
7## Using `stack-to-nix`
9With [nix-tools](https://github.com/input-output-hk/nix-tools) in
10`PATH`, we can simply run the following command on a stack project:
12```bash
13stack-to-nix -o nix --stack-yaml stack.yaml
14```
16This will produce a `nix/pkgs.nix` file that looks like the following:
17```nix
19 resolver = "lts-12.17";
20 overlay = hackage:
21 {
22 packages = {
23 "o-clock" = hackage.o-clock."0.1.1".revisions.default;
24 ...
25 } // {
26 my-package = ./my-package.nix;
27 ...
28 };
29 };
31```
33This file contains the stackage resolver, as well as an overlay of
34packages. The overlay specifies which `extra-deps` (here: o-clock-0.1.1)
35we wanted to overlay over the stackage snapshot, and what local
36packages we want (here: my-package).
38We will then create the following `nix/default.nix` file:
40```nix
41{ pkgs ? import <nixpkgs> {} }:
43let
44 haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) { inherit pkgs; };
46 pkgSet = haskell.mkStackPkgSet {
47 stack-pkgs = import ./pkgs.nix;
48 pkg-def-overlays = [];
49 modules = [];
50 };
52in
53 pkgSet.config.hsPkgs
54```
56This generated file is a template, so you can customize it as
57necessary.
59*If you came here from the [User Guide](/user-guide), go back and
60 complete the setup.*