on iko/ghcjs-patch-master help sign in
Move builder flatDepends to haskellLib.flatLibDepends

This function is also useful for the hoogle index builder.

commita4479de7cd32618413f498a8e9da22c0131e6e02 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateSun 26 May 2019, 16:37 (7 years ago) parent5576a98
2 files changed+13−10
builder/make-config-files.nix+1−10 lib/default.nix+12
builder/make-config-files.nix+1−10
@@ -6,15 +6,6 @@ let
66 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
77 '';
88
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−
189 exactDep = pdbArg: p: ''
1910 if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then
2011 echo "--dependency=${p}=$id" >> $out/configure-flags
@@ -58,7 +49,7 @@ in { identifier, component, fullName, flags ? {} }:
5849
5950 ${lib.concatMapStringsSep "\n" (p: ''
6051 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)}
6253
6354 # Note: we pass `clear` first to ensure that we never consult the implicit global package db.
6455 ${flagsAndConfig "package-db" ["clear" "$out/package.conf.d"]}
lib/default.nix+12
@@ -80,4 +80,16 @@ with haskellLib;
8080 let f' = if lib.isFunction f then f else import f;
8181 args' = (builtins.intersectAttrs (builtins.functionArgs f') scope) // args;
8282 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;
8395}