|
| 1 | +{ pkgs ? import <nixpkgs> {} |
| 2 | +}: |
| 3 | + |
1 | 4 | let |
2 | 5 | # pkg-def's may reference boot packages, but those |
3 | 6 | # are not guaranteed to be available on hackage, as |
|
13 | 16 | then filterAttrs (k: _: !(builtins.elem k boot-pkgs)) v |
14 | 17 | else v) |
15 | 18 | (pkg-def hackage); |
16 | | -in |
17 | | -hackage: let haskell = rec { |
| 19 | + |
18 | 20 | # ghc hackage patches. |
19 | 21 | # these are patches that turn hackage packages into the same as the ones |
20 | 22 | # ghc ships with the supposedly same version. See GHC Track Issue: 16199 |
21 | 23 | ghcHackagePatches = import ./patches; |
22 | 24 |
|
23 | | - compat = import ./compat.nix; |
| 25 | + compat = import ./lib/compat.nix; |
| 26 | + |
| 27 | + # Utility function for downloading a pinned git repo, that can be |
| 28 | + # overridden with NIX_PATH. |
| 29 | + fetchExternal = import ./lib/fetch-external.nix; |
| 30 | + |
| 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"; |
| 36 | + }); |
| 37 | + |
| 38 | + # The set of all Stackage snapshots |
| 39 | + stackage = import (fetchExternal { |
| 40 | + name = "stackage-snapshot-source"; |
| 41 | + specJSON = ./stackage-src.json; |
| 42 | + override = "stackage"; |
| 43 | + }); |
| 44 | + |
| 45 | + packages = self: ({ |
| 46 | + # Utility functions for working with the component builder. |
| 47 | + haskellLib = let hl = import ./lib { inherit (pkgs) lib; haskellLib = hl; }; in hl; |
24 | 48 |
|
25 | | - mkPkgSet |
26 | | - = { pkgs, pkg-def, pkg-def-overlays ? [], modules ? [] }@args: |
27 | | - import ./package-set.nix (args // { inherit hackage; pkg-def = strip-pkg-def pkgs pkg-def; }); |
| 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). |
| 51 | + mkPkgSet = |
| 52 | + { pkg-def # Base package set. Either from stackage (via stack-to-nix) or from a cabal projects plan file (via plan-to-nix) |
| 53 | + , pkg-def-overlays ? [] # Additional packages to augment the Base package set `pkg-def` with. |
| 54 | + , modules ? [] |
| 55 | + }@args: |
28 | 56 |
|
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; |
| 60 | + }); |
30 | 61 |
|
31 | | -}; in haskell |
| 62 | + # Create a Haskell package set based on a Stack configuration. |
| 63 | + mkStackPkgSet = |
| 64 | + { stack-pkgs # Path to the output of stack-to-nix |
| 65 | + , pkg-def-overlays ? [] |
| 66 | + , modules ? [] |
| 67 | + }@args: |
| 68 | + |
| 69 | + let |
| 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; |
| 74 | + in self.mkPkgSet { |
| 75 | + inherit pkg-def; |
| 76 | + pkg-def-overlays = [ stack-pkgs.overlay ] ++ pkg-def-overlays; |
| 77 | + modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules; |
| 78 | + }; |
| 79 | + |
| 80 | + # Programs for generating Nix expressions from Cabal and Stack |
| 81 | + # files. |
| 82 | + nix-tools = self.callPackage ./nix-tools { |
| 83 | + inherit fetchExternal; |
| 84 | + }; |
| 85 | + |
| 86 | + # Snapshots of Hackage and Stackage, converted to Nix expressions, |
| 87 | + # regularly updated. |
| 88 | + inherit hackage stackage; |
| 89 | + |
| 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 {}; |
| 94 | + }; |
| 95 | + }); |
| 96 | + |
| 97 | +in |
| 98 | + pkgs.lib.makeScope pkgs.newScope packages |
0 commit comments