@@ -1,3 +1,6 @@
1+{ pkgs ? import <nixpkgs> {}
2 # pkg-def's may reference boot packages, but those
5 # pkg-def's may reference boot packages, but those
3 # are not guaranteed to be available on hackage, as
6 # are not guaranteed to be available on hackage, as
@@ -13,19 +16,83 @@ let
13 then filterAttrs (k: _: !(builtins.elem k boot-pkgs)) v
16 then filterAttrs (k: _: !(builtins.elem k boot-pkgs)) v
15 (pkg-def hackage);
18 (pkg-def hackage);
17−hackage: let haskell = rec {
18 # ghc hackage patches.
20 # ghc hackage patches.
19 # these are patches that turn hackage packages into the same as the ones
21 # these are patches that turn hackage packages into the same as the ones
20 # ghc ships with the supposedly same version. See GHC Track Issue: 16199
22 # ghc ships with the supposedly same version. See GHC Track Issue: 16199
21 ghcHackagePatches = import ./patches;
23 ghcHackagePatches = import ./patches;
23− compat = import ./compat.nix;
25+ compat = import ./lib/compat.nix;
27+ # Utility function for downloading a pinned git repo, that can be
28+ # overridden with NIX_PATH.
29+ fetchExternal = import ./lib/fetch-external.nix;
31+ # All packages from Hackage as Nix expressions
32+ hackage = import (fetchExternal {
33+ name = "hackage-exprs-source";
34+ specJSON = ./hackage-src.json;
35+ override = "hackage";
38+ # The set of all Stackage snapshots
39+ stackage = import (fetchExternal {
40+ name = "stackage-snapshot-source";
41+ specJSON = ./stackage-src.json;
42+ override = "stackage";
46+ # Utility functions for working with the component builder.
47+ haskellLib = let hl = import ./lib { inherit (pkgs) lib; haskellLib = hl; }; in hl;
49+ # Create a Haskell package set based on a cabal build plan (plan-to-nix)
50+ # and Nix expressions representing cabal packages (cabal-to-nix).
25− mkPkgSet
51+ mkPkgSet =
26− = { pkgs, pkg-def, pkg-def-overlays ? [], modules ? [] }@args:
52+ { pkg-def # Base package set. Either from stackage (via stack-to-nix) or from a cabal projects plan file (via plan-to-nix)
27− import ./package-set.nix (args // { inherit hackage; pkg-def = strip-pkg-def pkgs pkg-def; });
53+ , pkg-def-overlays ? [] # Additional packages to augment the Base package set `pkg-def` with.
29− mkNewPkgSet = args: builtins.trace "DEPRECATED: use mkPkgSet instead of mkNewPkgSet" (mkPkgSet args);
57+ import ./package-set.nix (args // {
58+ inherit hackage pkgs;
59+ pkg-def = strip-pkg-def pkgs pkg-def;
31−}; in haskell
62+ # Create a Haskell package set based on a Stack configuration.
64+ { stack-pkgs # Path to the output of stack-to-nix
65+ , pkg-def-overlays ? []
70+ # The Stackage release referenced in the stack config
71+ pkg-def = stackage.${stack-pkgs.resolver};
72+ # The compiler referenced in the stack config
73+ compiler = (stack-pkgs.overlay hackage).compiler or (pkg-def hackage).compiler;
76+ pkg-def-overlays = [ stack-pkgs.overlay ] ++ pkg-def-overlays;
77+ modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules;
80+ # Programs for generating Nix expressions from Cabal and Stack
82+ nix-tools = self.callPackage ./nix-tools {
83+ inherit fetchExternal;
86+ # Snapshots of Hackage and Stackage, converted to Nix expressions,
88+ inherit hackage stackage;
90+ # Scripts for keeping Hackage and Stackage up to date.
91+ maintainer-scripts = {
92+ update-hackage = self.callPackage ./scripts/update-hackage.nix {};
93+ update-stackage = self.callPackage ./scripts/update-stackage.nix {};
98+ pkgs.lib.makeScope pkgs.newScope packages