on iko/ghcjs-patch-master help sign in
adds new-package-set.nix
commit03610ebc16eae35bce38eb2584bfdbddfb7d1425 authorMoritz Angermann <moritz.angermann@gmail.com> dateTue 23 Oct 2018, 16:22 (8 years ago) parent1673b94
1 file changed+91
new-package-set.nix+91
new-package-set.nixnew file+91
@@ -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
5+}:
6+
7+(pkgs.lib.fix (self: with self; {
8+ inherit (pkgs) lib stdenv;
9+ ghc = pkgs.haskell.compiler.${plan.compiler.nix-name};
10+
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');
17+
18+ haskellLib = import ./lib { inherit lib haskellLib; };
19+
20+ hackageConfigs =
21+ lib.flip lib.mapAttrs hackage
22+ (pname: lib.mapAttrs
23+ (vnum: version: version // {
24+ revisions =
25+ let
26+ rev2Config = rev: {
27+ inherit (version) sha256;
28+ inherit (rev) outPath;
29+ revision = rev.revNum;
30+ revisionSha256 = rev.sha256;
31+ };
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}
39+ else rev;
40+ };
41+ contentAddressedRevs = lib.foldr f {} (builtins.attrValues version.revisions);
42+ in lib.mapAttrs (_: rev2Config) (version.revisions // contentAddressedRevs);
43+ }));
44+ plan =
45+ let p = planFunc hackageConfigs;
46+ in p // {
47+ packages = hsPkgs:
48+ let
49+ args = {
50+ inherit hsPkgs compiler system pkgconfPkgs;
51+ pkgs = adjustedPkgs;
52+ };
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; })) {
57+ inherit flags;
58+ inherit (revision) sha256 revision revisionSha256;
59+ }
60+ )
61+ p.packages;
62+ };
63+
64+ cabal = import ./lib/cabal-os-arch-comp.nix;
65+
66+ compiler = cabal.compiler // {
67+ isGhc = true;
68+ version = lib.mapAttrs (_: f: v: f (builtins.compareVersions plan.compiler.version v)) {
69+ eq = c: c == 0;
70+ gt = c: c > 0;
71+ ge = c: c >= 0;
72+ lt = c: c < 0;
73+ le = c: c <= 0;
74+ };
75+ };
76+ system = let
77+ hostMap = import ./lib/host-map.nix pkgs.stdenv;
78+ in cabal.os // { "is${hostMap.os}" = true; }
79+ // cabal.arch // { "is${hostMap.arch}" = true; };
80+
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;
87+
88+ hsPkgs = weakCallPackage pkgs driver {
89+ inherit haskellLib ghc weakCallPackage plan;
90+ };
91+}))