mirror of
https://github.com/simplex-chat/haskell.nix.git
synced 2026-06-03 09:17:32 +00:00
* Updated the haskell.nix imports to overlay style Some of the examples in the documentation were still passing an empty set to the haskell.nix imports but this is no longer valid because the import now results in a set rather than a function. * Fix overlay imports in docs Import an overlayed nixpkgs rather than just the overlay. Thanks to angerman for noticing this error.
1.5 KiB
1.5 KiB
Here we will look into how to generate the pkgs.nix file for a
stack.yaml project. For the full integration see the
previous page.
Using stack-to-nix
With nix-tools installed, we can simply run the following command on a stack project:
stack-to-nix --output . --stack-yaml stack.yaml
This will produce a pkgs.nix file that looks like the following:
{
resolver = "lts-12.17";
extras = hackage:
{
packages = {
"o-clock" = hackage.o-clock."0.1.1".revisions.default;
...
} // {
my-package = ./my-package.nix;
...
};
};
}
This file contains the stackage resolver, as well as set of extra
packages. The extras specifies which extra-deps (here:
o-clock-0.1.1) we wanted to add over the stackage snapshot, and what
local packages we want (here: my-package).
Creating the package set
Import the generated pkgs.nix and pass to
mkStackPkgSet to
instantiate a package set.
# default.nix
let
# Import the Haskell.nix library,
src = builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz;
nixpkgs = import (src + "/nixpkgs") (import src);
haskell = nixpkgs.haskell-nix;
# Instantiate a package set using the generated file.
pkgSet = haskell.mkStackPkgSet {
stack-pkgs = import ./pkgs.nix;
pkg-def-overlays = [];
modules = [];
};
in
pkgSet.config.hsPkgs