@@ -0,0 +1,91 @@
1+{ pkgs ? import <nixpkgs> {}
2+, planFunc ? import ../stackage/lts-11.4.nix
3+, hackage ? import ../hackage
4+, driver ? ./nix/component-driver.nix
7+(pkgs.lib.fix (self: with self; {
8+ inherit (pkgs) lib stdenv;
9+ ghc = pkgs.haskell.compiler.${plan.compiler.nix-name};
11+ # Avoid pkgs.callPackage for now. It does a lot of nonsense with OOP
12+ # style programming that we should avoid until we know we want it.
13+ weakCallPackage = scope: f: args:
14+ let f' = if lib.isFunction f then f else import f;
15+ args' = scope // args;
16+ in f' (builtins.intersectAttrs (builtins.functionArgs f') args');
18+ haskellLib = import ./lib { inherit lib haskellLib; };
21+ lib.flip lib.mapAttrs hackage
23+ (vnum: version: version // {
27+ inherit (version) sha256;
28+ inherit (rev) outPath;
29+ revision = rev.revNum;
30+ revisionSha256 = rev.sha256;
32+ f = rev: acc: acc // {
33+ # If there's a collision (e.g. a revision was
34+ # reverted), pick the one with the smaller
35+ # revNum. They're identical, but if the smaller one is
36+ # r0 then we don't have to download a cabal file.
37+ ${rev.sha256} = if lib.hasAttr rev.sha256 acc && acc.${rev.sha256}.revNum < rev.revNum
38+ then acc.${rev.sha256}
41+ contentAddressedRevs = lib.foldr f {} (builtins.attrValues version.revisions);
42+ in lib.mapAttrs (_: rev2Config) (version.revisions // contentAddressedRevs);
45+ let p = planFunc hackageConfigs;
50+ inherit hsPkgs compiler system pkgconfPkgs;
53+ in lib.mapAttrs (pname: { revision, flags ? {} }: self:
54+ # Set the flags with the rhs of the recursiveUpdate, but
55+ # pass the final choice in flags using open recursion.
56+ lib.recursiveUpdate (import revision (args // { inherit (self) flags; })) {
58+ inherit (revision) sha256 revision revisionSha256;
64+ cabal = import ./lib/cabal-os-arch-comp.nix;
66+ compiler = cabal.compiler // {
68+ version = lib.mapAttrs (_: f: v: f (builtins.compareVersions plan.compiler.version v)) {
77+ hostMap = import ./lib/host-map.nix pkgs.stdenv;
78+ in cabal.os // { "is${hostMap.os}" = true; }
79+ // cabal.arch // { "is${hostMap.arch}" = true; };
81+ adjustedPkgs = pkgs // (import ./lib/system-nixpkgs-map.nix pkgs);
82+ pkgconfPkgs = pkgs // (import ./lib/pkgsconf-nixpkgs-map.nix pkgs);
83+ # hsPkgs = adjustedPkgs
84+ # // { buildPackages = hsPkgs; }
85+ # // lib.mapAttrs (_: _: null) (plan.compiler.packages // { hsc2hs = "0.68.2"; })
86+ # // lib.mapAttrs (_: driver) configs;
88+ hsPkgs = weakCallPackage pkgs driver {
89+ inherit haskellLib ghc weakCallPackage plan;