Skip to content

Instantly share code, notes, and snippets.

@lf-
Created August 6, 2020 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf-/96c72180db1a4c0974a8737b7c423c23 to your computer and use it in GitHub Desktop.
Save lf-/96c72180db1a4c0974a8737b7c423c23 to your computer and use it in GitHub Desktop.
# Applies a list of overlays to the haskell package set rather than the entire
# nixpkgs, removing five levels of unsightly indentation.
{ overlays, ghcVer }:
self: super:
let
inherit (super.lib) foldr composeExtensions;
foldExtensions = foldr composeExtensions (_: _: {});
in {
haskell = super.haskell // {
packages = super.haskell.packages // {
# overriding haskellPackages can produce surprising behaviour when
# multiple overrides are applied. We need to remember to include previous
# overrides in our overriding.
# https://github.com/NixOS/nixpkgs/issues/26561#issuecomment-354862897
"${ghcVer}" = super.haskell.packages."${ghcVer}".override (old: {
overrides = composeExtensions
(old.overrides or (_: _: {}))
(foldExtensions (builtins.map (f: f { nixpkgs = self; }) overlays));
});
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment