|
16 | 16 |
|
17 | 17 | haskellLib = import ./lib.nix { inherit lib haskellLib; };
|
18 | 18 |
|
19 |
| - plan = |
20 |
| - let p = planFunc hackageConfigs; |
21 |
| - in p // { |
22 |
| - packages = lib.mapAttrs |
23 |
| - (_: pkg: self: |
24 |
| - lib.recursiveUpdate (pkg.revision self) { flags = pkg.flags or {}; } |
25 |
| - ) p.packages; |
26 |
| - }; |
27 | 19 | hackageConfigs =
|
| 20 | + lib.flip lib.mapAttrs hackage |
| 21 | + (pname: lib.mapAttrs |
| 22 | + (vnum: version: version // { |
| 23 | + revisions = |
| 24 | + let |
| 25 | + rev2Config = rev: { |
| 26 | + inherit (version) sha256; |
| 27 | + inherit (rev) outPath; |
| 28 | + revision = rev.revNum; |
| 29 | + revisionSha256 = rev.sha256; |
| 30 | + }; |
| 31 | + f = rev: acc: acc // { |
| 32 | + # If there's a collision (e.g. a revision was |
| 33 | + # reverted), pick the one with the smaller |
| 34 | + # revNum. They're identical, but if the smaller one is |
| 35 | + # r0 then we don't have to download a cabal file. |
| 36 | + ${rev.sha256} = if lib.hasAttr rev.sha256 acc && acc.${rev.sha256}.revNum < rev.revNum |
| 37 | + then acc.${rev.sha256} |
| 38 | + else rev; |
| 39 | + }; |
| 40 | + contentAddressedRevs = lib.foldr f {} (builtins.attrValues version.revisions); |
| 41 | + in lib.mapAttrs (_: rev2Config) (version.revisions // contentAddressedRevs); |
| 42 | + })); |
| 43 | + plan = |
28 | 44 | let
|
29 | 45 | args = {
|
30 | 46 | inherit hsPkgs compiler system pkgconfPkgs;
|
31 | 47 | pkgs = adjustedPkgs;
|
32 | 48 | };
|
33 |
| - handleVer = vdata: |
34 |
| - let |
35 |
| - revs = builtins.removeAttrs vdata ["sha256"]; |
36 |
| - rev2HashedConfig = name: rev: { name = rev.cabalSha256; value = revConfigs.${name}; }; |
37 |
| - revConfigs = lib.mapAttrs (_: rev2config vdata.sha256) revs; |
38 |
| - in revConfigs // lib.mapAttrs' rev2HashedConfig revs; |
39 |
| - rev2config = sha256: rev: self: import rev (args // { inherit (self) flags; }) // { |
40 |
| - inherit sha256; |
41 |
| - inherit (rev) cabalFile; |
42 |
| - }; |
43 |
| - in lib.mapAttrs (_: lib.mapAttrs (_: handleVer)) hackage; |
| 49 | + p = planFunc hackageConfigs; |
| 50 | + in p // { |
| 51 | + packages = lib.mapAttrs |
| 52 | + (pname: { revision, flags ? {} }: self: |
| 53 | + # Set the flags with the rhs of the recursiveUpdate, but |
| 54 | + # pass the final choice in flags using open recursion. |
| 55 | + lib.recursiveUpdate (import revision (args // { inherit (self) flags; })) { |
| 56 | + inherit flags; |
| 57 | + inherit (revision) sha256 revision revisionSha256; |
| 58 | + } |
| 59 | + ) |
| 60 | + p.packages; |
| 61 | + }; |
44 | 62 |
|
45 | 63 | new-builder = weakCallPackage pkgs ./new-builder.nix {
|
46 | 64 | inherit haskellLib ghc weakCallPackage;
|
|
0 commit comments