@@ -1,153 +0,0 @@
1−{ lib, haskellLib }:
2−
3−with haskellLib;
4−
5−{
6− subComponentTypes = [
7− "sublibs"
8− "foreignlibs"
9− "exes"
10− "tests"
11− "benchmarks"
12− ];
13−
14− mergeComponents = lib.zipAttrsWith (_: comps: lib.genAttrs [
15− "depends"
16− "libs"
17− "frameworks"
18− "pkgconfig"
19− "build-tools"
20− ] (n: {
21− ${n} = lib.concatMap (comp: comp.${n} or []) comps;
22− }));
23−
24− unionrAttrs = lib.foldr (a: b: a // b) {};
25−
26− mergeConfigs = configs:
27− let
28− mergeComponentType = type: mergeComponents (map (conf: (conf.components or {}).${type} or {}) configs);
29− in unionrAttrs configs // {
30− flags = unionrAttrs (map (conf: conf.flags or {}) configs);
31− package = lib.foldr (conf: lib.recursiveUpdate (conf.package or {})) {} configs;
32− components =
33− mergeComponents (map (conf: removeAttrs (conf.components or {}) subComponentTypes) configs)
34− // lib.genAttrs subComponentTypes mergeComponentType;
35− configureFlags = concatMap (conf: conf.configureFlags or []) configs;
36− };
37−
38− foldrAttrVals = f: z: attrs:
39− lib.foldr (g: acc: g acc) z (lib.mapAttrsToList f attrs);
40−
41− attrLength = attrs: builtins.length (builtins.attrValues attrs);
42−
43− foldComponents = tys: f: z: conf:
44− let
45− comps = conf.components or {};
46− foldSection = foldrAttrVals f;
47− libComp = acc:
48− foldSection acc
49− (removeAttrs comps subComponentTypes);
50− subComps = acc:
51− lib.foldr
52− (ty: acc': foldSection acc' (comps.${ty} or {}))
53− acc
54− tys;
55− in libComp (subComps z);
56−
57− componentPrefix = {
58− # Are all of these right?
59− sublibs = "sublib";
60− foreignlibs = "foreignlib";
61− exes = "exe";
62− tests = "test";
63− benchmarks = "bench";
64− };
65−
66− applyComponents = f: comps:
67− let
68− libComp = lib.mapAttrs (cname: f {ctype="lib"; inherit cname;}) (removeAttrs comps subComponentTypes);
69− subComps = lib.mapAttrs
70− (ctype: lib.mapAttrs (cname: f {inherit cname; ctype=componentPrefix.${ctype};}))
71− (builtins.intersectAttrs (lib.genAttrs subComponentTypes (_: null)) comps);
72− in subComps // libComp;
73−
74− isLibrary = componentId: componentId.ctype == "lib";
75−
76− adjustHackage = hackage: args:
77− let
78− handleVer = vdata:
79− let
80− revs = builtins.removeAttrs vdata ["sha256"];
81− rev2HashedConfig = name: rev: { name = rev.cabalSha256; value = revConfigs.${name}; };
82− revConfigs = lib.mapAttrs (_: rev2config vdata.sha256) revs;
83− in revConfigs // lib.mapAttrs' rev2HashedConfig revs;
84− rev2config = sha256: rev: self: import rev (args // { inherit (self) flags; }) // {
85− inherit sha256;
86− inherit (rev) cabalFile;
87− };
88− in lib.mapAttrs (_: lib.mapAttrs (_: handleVer)) hackage;
89−
90− buildPlan = { pkgs, plan }:
91− let
92− ghc = pkgs.haskell.compiler.${plan.compiler.nix-name};
93− weakCallPackage = scope: f: args:
94− let f' = if lib.isFunction f then f else import f;
95− args' = scope // args;
96− in f' (builtins.intersectAttrs (builtins.functionArgs f') args');
97−
98− new-builder = weakCallPackage pkgs ./builder {
99− inherit haskellLib ghc weakCallPackage;
100− };
101− cabal = import ./lib/cabal-os-arch-comp.nix;
102− configs = lib.mapAttrs (_: lib.fix) plan.packages;
103− in {
104− system =
105− let hostMap = import ./lib/host-map.nix pkgs.stdenv;
106− in cabal.os // { "is${hostMap.os}" = true; }
107− // cabal.arch // { "is${hostMap.arch}" = true; };
108− compiler = cabal.compiler // {
109− isGhc = true;
110− version = lib.mapAttrs (_: f: v: f (builtins.compareVersions plan.compiler.version v)) {
111− eq = c: c == 0;
112− gt = c: c > 0;
113− ge = c: c >= 0;
114− lt = c: c < 0;
115− le = c: c <= 0;
116− };
117− };
118− pkgconfPkgs = pkgs // {
119− cairo-pdf = pkgs.cairo;
120− cairo-ps = pkgs.cairo;
121− cairo-svg = pkgs.cairo;
122− xft = pkgs.xorg.libXft;
123− xau = pkgs.xorg.libXau;
124− libR = pkgs.R;
125− fftw3f = pkgs.fftwFloat;
126− fftw3 = pkgs.fftw;
127− };
128− pkgs = pkgs // {
129− pthread = null;
130− "stdc++" = null;
131− ssl = pkgs.openssl.dev;
132− crypto = pkgs.openssl.dev;
133− z = pkgs.zlib;
134− GL = pkgs.libGL;
135− GLU = pkgs.libGLU;
136− alut = pkgs.freealut;
137− X11 = pkgs.xorg.libX11;
138− Xrandr = pkgs.xorg.libXrandr;
139− Xext = pkgs.xorg.libXext;
140− Xi = pkgs.xorg.libXi;
141− Xxf86vm = pkgs.xorg.libXxf86vm;
142− Xcursor = pkgs.xorg.libXcursor;
143− Xinerama = pkgs.xorg.libXinerama;
144− mysqlclient = pkgs.mysql;
145− Imlib2 = pkgs.imlib2;
146− asound = pkgs.alsaLib;
147− ffi = null;
148− };
149− hsPkgs = lib.mapAttrs (_: _: null) (plan.compiler.packages // { hsc2hs = "0.68.2"; })
150− // lib.mapAttrs (_: new-builder) configs;
151− };
152−
153−}