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:

with import < nixpkgs > {}; importnixpkgs{}; haskell.packages.stackage.lts-100.override { overrides = self: super: { = self: super: { mkDerivation = args: super.mkDerivation (args // { = args: super.mkDerivation (args // { enableLibraryProfiling = true ; = true }); }; }

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.

{ nixpkgs ? import < nixpkgs > { } }: ? importnixpkgs}: nixpkgs.haskell.packages.stackage.lib.callStackage2nix "my-package" ./. { ./. { inherit nixpkgs ; nixpkgs };

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

let nixpkgs = import ./nixpkgs-pinned.nix {}; = import ./nixpkgs-pinned.nix {}; inherit (nixpkgs) pkgs lib haskell ; (nixpkgs)lib haskell stackage2nixSrc = pkgs.fetchFromGitHub (lib.importJSON ./stackage2nix.json); = pkgs.fetchFromGitHub (lib.importJSON ./stackage2nix.json); stackagePackages = haskell.packages.stackage.lib.callStackage2nix "stackage2nix" stackage2nixSrc { inherit nixpkgs ; }; = haskell.packages.stackage.lib.callStackage2nixstackage2nixSrc { inherit nixpkgs}; stackage = stackagePackages.override { = stackagePackages.override { overrides = self: super: { = self: super: { stackage2nix = haskell.lib.disableSharedExecutables super.stackage2nix ; = haskell.lib.disableSharedExecutables super.stackage2nix }; }; in stackage

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.