on iko/ghcjs-patch-master help sign in
Add `package.buildable` option (#1205)
3835023Hamish Mackenzie
lib/default.nix+6−2
@@ -73,8 +73,12 @@ in {
73 comps = config.components;
73 comps = config.components;
74 applyLibrary = cname: f { cname = config.package.identifier.name; ctype = "lib"; };
74 applyLibrary = cname: f { cname = config.package.identifier.name; ctype = "lib"; };
75 applySubComp = ctype: cname: f { inherit cname; ctype = componentPrefix.${ctype} or (throw "Missing component mapping for ${ctype}."); };
75 applySubComp = ctype: cname: f { inherit cname; ctype = componentPrefix.${ctype} or (throw "Missing component mapping for ${ctype}."); };
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`
76− buildableAttrs = lib.filterAttrs (n: comp: comp.buildable or true && comp.planned);
80+ buildableAttrs = lib.filterAttrs (n: isBuildable);
77− libComp = if comps.library == null || !(comps.library.buildable or true && comps.library.planned)
81+ libComp = if comps.library == null || !(isBuildable comps.library)
78 then {}
82 then {}
79 else lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "setup" ]));
83 else lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "setup" ]));
80 subComps = lib.mapAttrs
84 subComps = lib.mapAttrs
modules/package.nix+5
@@ -215,6 +215,11 @@ in {
215 type = bool;
215 type = bool;
216 default = false;
216 default = false;
217 };
217 };
218+
219+ buildable = mkOption {
220+ type = bool;
221+ default = true;
222+ };
218 };
223 };
219
224
220 components = {
225 components = {
test/unit.nix+8−6
@@ -6,23 +6,25 @@ let
6 benchmarks = { };
6 benchmarks = { };
7 exes = { };
7 exes = { };
8 foreignlibs = { };
8 foreignlibs = { };
9− library = { planned = true; };
9+ library = { buildable = true; planned = true; };
10 sublibs = { };
10 sublibs = { };
11 tests = { };
11 tests = { };
12 };
12 };
13 package.identifier.name = "empty";
13 package.identifier.name = "empty";
14+ package.buildable = true;
14 };
15 };
15
16
16 componentsConfig = {
17 componentsConfig = {
17 components = {
18 components = {
18− benchmarks = { bbb = { planned = true; }; };
19+ benchmarks = { bbb = { buildable = true; planned = true; }; };
19− exes = { eee = { planned = true; }; };
20+ exes = { eee = { buildable = true; planned = true; }; };
20− foreignlibs = { fff = { planned = true; }; };
21+ foreignlibs = { fff = { buildable = true; planned = true; }; };
21− library = { planned = true; };
22+ library = { buildable = true; planned = true; };
22 sublibs = { };
23 sublibs = { };
23− tests = { ttt = { planned = true; }; };
24+ tests = { ttt = { buildable = true; planned = true; }; };
24 };
25 };
25 package.identifier.name = "nnn";
26 package.identifier.name = "nnn";
27+ package.buildable = true;
26 };
28 };
27
29
28 testRepoData = {
30 testRepoData = {