on iko/ghcjs-patch-master help sign in
shell-for: component selection for flatDepends
commitc7654b432310531eb70c00878623c0b611b769cd authorKosyrev Serge <serge.kosyrev@iohk.io> dateThu 16 May 2019, 18:22 (7 years ago) parentcde9b82
1 file changed+21−3
builder/make-config-files.nix+21−3
builder/make-config-files.nix+21−3
@@ -1,14 +1,32 @@
11{ stdenv, lib, haskellLib, ghc, nonReinstallablePkgs, runCommand }:
22
3+with builtins; with lib;
34let
45 flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
56 echo ${lib.concatStringsSep " " (map (x: "--${field}=${x}") xs)} >> $out/configure-flags
67 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
78 '';
89
9− flatDepends = component:
10+ ## packageComponentsOfType :: Package -> Type String -> [Component]
11+ packageComponentsOfType = pkg: type:
12+ (optionals (hasAttr type pkg.components) (lib.mapAttrsToList (n: c: c) pkg.components."${type}"));
13+ ## packageComponentsOfType :: Package -> [Component]
14+ packageComponents = pkg:
15+ optionals (hasAttr "library" pkg.components) [ pkg.components.library ]
16+ ++ concatMap (packageComponentsOfType pkg) ["sublibs" "exes" "foreignlibs" "tests" "benchmarks"];
17+ ## packageKeyComponent :: Package -> Component
18+ packageKeyComponent = pkg:
19+ let comps = packageComponents pkg;
20+ first = elemAt comps 0;
21+ r = if length comps == 0
22+ then throw "No components in package ${pkg.identifier.name}."
23+ else first; in
24+ r;
25+ ## flatDepends :: Component -> [Package]
26+ flatDepends =
27+ component:
1028 let
11− makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
29+ makePairs = map (p: rec { key="${val.name}"; val=packageKeyComponent p; });
1230 closure = builtins.genericClosure {
1331 startSet = makePairs component.depends;
1432 operator = {val,...}: makePairs val.config.depends;
@@ -69,7 +87,7 @@ in { identifier, component, fullName, flags ? {} }:
6987 cat > $out/ghc-environment <<EOF
7088 package-db $out/package.conf.d
7189 EOF
72− ${lib.concatMapStringsSep "\n" (p: envDep "--package-db ${p.components.library or p}/package.conf.d" p.identifier.name) component.depends}
90+ ${lib.concatMapStringsSep "\n" (p: envDep "--package-db ${packageKeyComponent p}/package.conf.d" p.identifier.name) component.depends}
7391 ${lib.concatMapStringsSep "\n" (envDep "") (lib.remove "ghc" nonReinstallablePkgs)}
7492
7593 '' + lib.optionalString component.doExactConfig ''