on iko/ghcjs-patch-master help sign in
Add an "all" component
73f3733Rodney Lorrimar
builder/comp-builder.nix+7−5
@@ -17,7 +17,7 @@
17, preCheck ? null, postCheck ? null
17, preCheck ? null, postCheck ? null
18, preInstall ? null, postInstall ? null
18, preInstall ? null, postInstall ? null
19
19
20−, doCheck ? component.doCheck || componentId.ctype == "test"
20+, doCheck ? component.doCheck || haskellLib.isTest componentId
21, doCrossCheck ? component.doCrossCheck || false
21, doCrossCheck ? component.doCrossCheck || false
22, dontPatchELF ? true
22, dontPatchELF ? true
23, dontStrip ? true
23, dontStrip ? true
@@ -27,7 +27,9 @@
27}:
27}:
28
28
29let
29let
30+ fullName = if haskellLib.isAll componentId
31+ then "${name}-all"
30− fullName = "${name}-${componentId.ctype}-${componentId.cname}";
32+ else "${name}-${componentId.ctype}-${componentId.cname}";
31
33
32 flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
34 flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
33 echo ${lib.concatStringsSep " " (map (x: "--${field}=${x}") xs)} >> $out/configure-flags
35 echo ${lib.concatStringsSep " " (map (x: "--${field}=${x}") xs)} >> $out/configure-flags
@@ -122,7 +124,7 @@ let
122
124
123 finalConfigureFlags = lib.concatStringsSep " " (
125 finalConfigureFlags = lib.concatStringsSep " " (
124 [ "--prefix=$out"
126 [ "--prefix=$out"
125− "${componentId.ctype}:${componentId.cname}"
127+ "${haskellLib.componentTarget componentId}"
126 "$(cat ${configFiles}/configure-flags)"
128 "$(cat ${configFiles}/configure-flags)"
127 # GHC
129 # GHC
128 "--with-ghc=${ghc.targetPrefix}ghc"
130 "--with-ghc=${ghc.targetPrefix}ghc"
@@ -217,12 +219,12 @@ in stdenv.mkDerivation ({
217 installPhase = ''
219 installPhase = ''
218 runHook preInstall
220 runHook preInstall
219 $SETUP_HS copy ${lib.concatStringsSep " " component.setupInstallFlags}
221 $SETUP_HS copy ${lib.concatStringsSep " " component.setupInstallFlags}
220− ${lib.optionalString (haskellLib.isLibrary componentId) ''
222+ ${lib.optionalString (haskellLib.isLibrary componentId || haskellLib.isAll componentId) ''
221 $SETUP_HS register --gen-pkg-config=${name}.conf
223 $SETUP_HS register --gen-pkg-config=${name}.conf
222 ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
224 ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
223 ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
225 ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
224 ''}
226 ''}
225− ${lib.optionalString (componentId.ctype == "test") ''
227+ ${lib.optionalString (haskellLib.isTest componentId || haskellLib.isAll componentId) ''
226 mkdir -p $out/${name}
228 mkdir -p $out/${name}
227 if [ -f "dist/build/${componentId.cname}/${componentId.cname}" ]; then
229 if [ -f "dist/build/${componentId.cname}/${componentId.cname}" ]; then
228 cp dist/build/${componentId.cname}/${componentId.cname} $out/${name}/
230 cp dist/build/${componentId.cname}/${componentId.cname} $out/${name}/
lib/default.nix+17−3
@@ -3,6 +3,8 @@
3with haskellLib;
3with haskellLib;
4
4
5{
5{
6+ # Within the package components, these are the attribute names of
7+ # nested attrsets.
6 subComponentTypes = [
8 subComponentTypes = [
7 "sublibs"
9 "sublibs"
8 "foreignlibs"
10 "foreignlibs"
@@ -66,13 +68,25 @@ with haskellLib;
66 applyComponents = f: config:
68 applyComponents = f: config:
67 let
69 let
68 comps = config.components;
70 comps = config.components;
71+ applyLibrary = cname: f { cname = config.package.identifier.name; ctype = "lib"; };
72+ applySubComp = ctype: cname: f { inherit cname; ctype = componentPrefix.${ctype}; };
73+ applyAllComp = f { cname = config.package.identifier.name; ctype = "all"; };
69− libComp = lib.mapAttrs (cname: f {ctype="lib"; cname=config.package.identifier.name;}) (removeAttrs comps subComponentTypes);
74+ libComp = lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "all" ]));
70 subComps = lib.mapAttrs
75 subComps = lib.mapAttrs
71− (ctype: lib.mapAttrs (cname: f {inherit cname; ctype=componentPrefix.${ctype};}))
76+ (ctype: lib.mapAttrs (applySubComp ctype))
72 (builtins.intersectAttrs (lib.genAttrs subComponentTypes (_: null)) comps);
77 (builtins.intersectAttrs (lib.genAttrs subComponentTypes (_: null)) comps);
78+ allComp = { all = applyAllComp comps.all; };
73− in subComps // libComp;
79+ in subComps // libComp // allComp;
74
80
75 isLibrary = componentId: componentId.ctype == "lib";
81 isLibrary = componentId: componentId.ctype == "lib";
82+ isAll = componentId: componentId.ctype == "all";
83+ isTest = componentId: componentId.ctype == "test";
84+
85+ # Format a componentId as it should appear as a target on the
86+ # command line of the setup script.
87+ componentTarget = componentId:
88+ if componentId.ctype == "all" then ""
89+ else "${componentId.ctype}:${componentId.cname}";
76
90
77 # Avoid pkgs.callPackage for now. It does a lot of nonsense with OOP
91 # Avoid pkgs.callPackage for now. It does a lot of nonsense with OOP
78 # style programming that we should avoid until we know we want it.
92 # style programming that we should avoid until we know we want it.
modules/package.nix+9
@@ -173,6 +173,15 @@ in {
173 type = attrsOf (componentType false);
173 type = attrsOf (componentType false);
174 default = {};
174 default = {};
175 };
175 };
176+ all = mkOption {
177+ type = componentType false;
178+ default = let
179+ componentTypes = [ "library" "sublibs" "foreignlibs" "exes" "tests" "benchmarks" ];
180+ in {
181+ depends = mkMerge (map (c: config.components.${c}.depends or []) componentTypes);
182+ };
183+ defaultText = "The merged dependencies of all other components";
184+ };
176 };
185 };
177
186
178 name = mkOption {
187 name = mkOption {