on iko/ghcjs-patch-master help sign in
Add `package.buildable` option (#1205)

* Add `package.buildable` option Turning off building for a whole package requires setting `buildable = lib.mkForce false` on each of the components of the package. This change adds support for `package.buildable = false` to make it easier. So: ``` packages.marlowe-actus.components.library.buildable = lib.mkForce false; packages.marlowe-actus.components.exes.marlowe-actus-test-kit.buildable = lib.mkForce false; packages.marlowe-actus.components.tests.marlowe-actus-test.buildable = lib.mkForce false; ``` Can be replaced with: ``` packages.marlowe-actus.package.buildable = false; ```

commit3835023cdabc78f1cbdb975015072624b98c61d0 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 19 Aug 2021, 00:52 (5 years ago) parentb950411
3 files changed+19−8
lib/default.nix+6−2 modules/package.nix+5 test/unit.nix+8−6
lib/default.nix+6−2
@@ -73,8 +73,12 @@ in {
7373 comps = config.components;
7474 applyLibrary = cname: f { cname = config.package.identifier.name; ctype = "lib"; };
7575 applySubComp = ctype: cname: f { inherit cname; ctype = componentPrefix.${ctype} or (throw "Missing component mapping for ${ctype}."); };
76− buildableAttrs = lib.filterAttrs (n: comp: comp.buildable or true && comp.planned);
77− libComp = if comps.library == null || !(comps.library.buildable or true && comps.library.planned)
76+ isBuildable = comp:
77+ config.package.buildable # Set manually in a module (allows whole packages to be disabled)
78+ && comp.buildable # Set based on `buildable` in `.cabal` files
79+ && comp.planned; # Set if the component was in the `plan.json`
80+ buildableAttrs = lib.filterAttrs (n: isBuildable);
81+ libComp = if comps.library == null || !(isBuildable comps.library)
7882 then {}
7983 else lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "setup" ]));
8084 subComps = lib.mapAttrs
modules/package.nix+5
@@ -215,6 +215,11 @@ in {
215215 type = bool;
216216 default = false;
217217 };
218+
219+ buildable = mkOption {
220+ type = bool;
221+ default = true;
222+ };
218223 };
219224
220225 components = {
test/unit.nix+8−6
@@ -6,23 +6,25 @@ let
66 benchmarks = { };
77 exes = { };
88 foreignlibs = { };
9− library = { planned = true; };
9+ library = { buildable = true; planned = true; };
1010 sublibs = { };
1111 tests = { };
1212 };
1313 package.identifier.name = "empty";
14+ package.buildable = true;
1415 };
1516
1617 componentsConfig = {
1718 components = {
18− benchmarks = { bbb = { planned = true; }; };
19− exes = { eee = { planned = true; }; };
20− foreignlibs = { fff = { planned = true; }; };
21− library = { planned = true; };
19+ benchmarks = { bbb = { buildable = true; planned = true; }; };
20+ exes = { eee = { buildable = true; planned = true; }; };
21+ foreignlibs = { fff = { buildable = true; planned = true; }; };
22+ library = { buildable = true; planned = true; };
2223 sublibs = { };
23− tests = { ttt = { planned = true; }; };
24+ tests = { ttt = { buildable = true; planned = true; }; };
2425 };
2526 package.identifier.name = "nnn";
27+ package.buildable = true;
2628 };
2729
2830 testRepoData = {