Stackage nixpkgs overlays

Posted on January 19, 2018 by Dmitry Bushev


Yesterday we published a typeable/nixpkgs-stackage Stackage Nixpkgs overlay plus a typeable/stackage2nix update with overlay support. Here’s a quick overview of new features.

Stackage nixpkgs overlays

Overlay adds Stackage LTS releases to Nixpkgs at the pkgs.haskell.packages.stackage.

You can use these Stackage packages the same way as original Hackage packages maintained by Nix. Below you will find some examples from Nixpkgs Haskell manual with haskellPackages replaced with LTS packages.

List packages in lts-10.0 release:

Create a development environment from LTS package set:

Override and enable profiling:

Stackage packages are generated with stackage2nix and will be updated on a regular basis.

stackage2nix build support

Overlay also adds build utils at pkgs.haskell.packages.stackage.lib. You can create a build derivation from your project’s stack.yaml using callStackage2nix helper function.

More complex example with pinned Nixpkgs, stackage2nix source pulled from GitHub, and overriding of the resulting Haskell packages:

callStackage2nix function calls stackage2nix on provided path and produces a derivation with Haskell packages for the project. nixpkgs-stackage/examples directory contains full source code of the derivations listed above.

stackage2nix

stackage2nix was also updated to support the Stackage overlay. Now the default is to create a single default.nix with an override of existing Stackage packages. The advantage of this approach is that it does not require additional --all-cabal-hashes and --lts-haskell flags (they are only needed for Stackage generation). But it is required to have typeable/nixpkgs-stackage overlay installed in the system.

To enable the old behavior and generate all packages required for the build, pass --with-stackage or --with-stackage-closure flags.