on iko/ghcjs-patch-master help sign in
Move builder flatDepends to haskellLib.flatLibDepends
a4479deRodney Lorrimar
builder/make-config-files.nix+1−10
@@ -6,15 +6,6 @@ let
6 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
6 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
7 '';
7 '';
8
8
9− flatDepends = component:
10− let
11− makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
12− closure = builtins.genericClosure {
13− startSet = makePairs component.depends;
14− operator = {val,...}: makePairs val.config.depends;
15− };
16− in map ({val,...}: val) closure;
17−
18 exactDep = pdbArg: p: ''
9 exactDep = pdbArg: p: ''
19 if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then
10 if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then
20 echo "--dependency=${p}=$id" >> $out/configure-flags
11 echo "--dependency=${p}=$id" >> $out/configure-flags
@@ -58,7 +49,7 @@ in { identifier, component, fullName, flags ? {} }:
58
49
59 ${lib.concatMapStringsSep "\n" (p: ''
50 ${lib.concatMapStringsSep "\n" (p: ''
60 target-pkg --package-db ${p}/package.conf.d dump | target-pkg --force --package-db $out/package.conf.d register -
51 target-pkg --package-db ${p}/package.conf.d dump | target-pkg --force --package-db $out/package.conf.d register -
61− '') (flatDepends component)}
52+ '') (haskellLib.flatLibDepends component)}
62
53
63 # Note: we pass `clear` first to ensure that we never consult the implicit global package db.
54 # Note: we pass `clear` first to ensure that we never consult the implicit global package db.
64 ${flagsAndConfig "package-db" ["clear" "$out/package.conf.d"]}
55 ${flagsAndConfig "package-db" ["clear" "$out/package.conf.d"]}
lib/default.nix+12
@@ -80,4 +80,16 @@ with haskellLib;
80 let f' = if lib.isFunction f then f else import f;
80 let f' = if lib.isFunction f then f else import f;
81 args' = (builtins.intersectAttrs (builtins.functionArgs f') scope) // args;
81 args' = (builtins.intersectAttrs (builtins.functionArgs f') scope) // args;
82 in f' args';
82 in f' args';
83+
84+ # Collect all (transitive) Haskell library dependencies of a
85+ # component.
86+ ## flatLibDepends :: Component -> [Package]
87+ flatLibDepends = component:
88+ let
89+ makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
90+ closure = builtins.genericClosure {
91+ startSet = makePairs component.depends;
92+ operator = {val,...}: makePairs val.config.depends;
93+ };
94+ in map ({val,...}: val) closure;
83}
95}