on a0b6afe help sign in
haskell.nix/docs/user-guide-stack.md
49 lines 1.3 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 > nix/.stack-pkgs.nix
14```
16This will produce a `nix/.stack-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 = ./.stack.nix/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: 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/pkgs.nix` file:
40```nix
41let stack-pkgs = import ./.stack-pkgs.nix; in
42{ stackage, ... }:
43{ pkg-def = stackage.${stack-pkgs.resolver};
44 inherit (stack-pkgs) overlay;
46```
48*If you came here from the [User Guide](/user-guide), go back and
49 complete the setup.*