on iko/ghcjs-patch-master help sign in
Add an "all" component
commit73f3733a2f0d698db8f3354fd743577bd1b12e1c authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateWed 30 Jan 2019, 15:25 (8 years ago) parentdae8025
3 files changed+33−8
builder/comp-builder.nix+7−5 lib/default.nix+17−3 modules/package.nix+9
builder/comp-builder.nix+7−5
@@ -17,7 +17,7 @@
1717, preCheck ? null, postCheck ? null
1818, preInstall ? null, postInstall ? null
1919
20−, doCheck ? component.doCheck || componentId.ctype == "test"
20+, doCheck ? component.doCheck || haskellLib.isTest componentId
2121, doCrossCheck ? component.doCrossCheck || false
2222, dontPatchELF ? true
2323, dontStrip ? true
@@ -27,7 +27,9 @@
2727}:
2828
2929let
30− fullName = "${name}-${componentId.ctype}-${componentId.cname}";
30+ fullName = if haskellLib.isAll componentId
31+ then "${name}-all"
32+ else "${name}-${componentId.ctype}-${componentId.cname}";
3133
3234 flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
3335 echo ${lib.concatStringsSep " " (map (x: "--${field}=${x}") xs)} >> $out/configure-flags
@@ -122,7 +124,7 @@ let
122124
123125 finalConfigureFlags = lib.concatStringsSep " " (
124126 [ "--prefix=$out"
125− "${componentId.ctype}:${componentId.cname}"
127+ "${haskellLib.componentTarget componentId}"
126128 "$(cat ${configFiles}/configure-flags)"
127129 # GHC
128130 "--with-ghc=${ghc.targetPrefix}ghc"
@@ -217,12 +219,12 @@ in stdenv.mkDerivation ({
217219 installPhase = ''
218220 runHook preInstall
219221 $SETUP_HS copy ${lib.concatStringsSep " " component.setupInstallFlags}
220− ${lib.optionalString (haskellLib.isLibrary componentId) ''
222+ ${lib.optionalString (haskellLib.isLibrary componentId || haskellLib.isAll componentId) ''
221223 $SETUP_HS register --gen-pkg-config=${name}.conf
222224 ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
223225 ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
224226 ''}
225− ${lib.optionalString (componentId.ctype == "test") ''
227+ ${lib.optionalString (haskellLib.isTest componentId || haskellLib.isAll componentId) ''
226228 mkdir -p $out/${name}
227229 if [ -f "dist/build/${componentId.cname}/${componentId.cname}" ]; then
228230 cp dist/build/${componentId.cname}/${componentId.cname} $out/${name}/
lib/default.nix+17−3
@@ -3,6 +3,8 @@
33with haskellLib;
44
55{
6+ # Within the package components, these are the attribute names of
7+ # nested attrsets.
68 subComponentTypes = [
79 "sublibs"
810 "foreignlibs"
@@ -66,13 +68,25 @@ with haskellLib;
6668 applyComponents = f: config:
6769 let
6870 comps = config.components;
69− libComp = lib.mapAttrs (cname: f {ctype="lib"; cname=config.package.identifier.name;}) (removeAttrs comps subComponentTypes);
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"; };
74+ libComp = lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "all" ]));
7075 subComps = lib.mapAttrs
71− (ctype: lib.mapAttrs (cname: f {inherit cname; ctype=componentPrefix.${ctype};}))
76+ (ctype: lib.mapAttrs (applySubComp ctype))
7277 (builtins.intersectAttrs (lib.genAttrs subComponentTypes (_: null)) comps);
73− in subComps // libComp;
78+ allComp = { all = applyAllComp comps.all; };
79+ in subComps // libComp // allComp;
7480
7581 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}";
7690
7791 # Avoid pkgs.callPackage for now. It does a lot of nonsense with OOP
7892 # style programming that we should avoid until we know we want it.
modules/package.nix+9
@@ -173,6 +173,15 @@ in {
173173 type = attrsOf (componentType false);
174174 default = {};
175175 };
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+ };
176185 };
177186
178187 name = mkOption {