summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-07-02 09:32:43 +0200
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-07-07 12:02:29 -0400
commitdfc004e69c23cb48cce2c7537169a81b299a0af9 (patch)
treeb297211c5ec12a3882e0940925687d74e4ae53ef
parent5afcdc88fa7ce9583eecec136de49685923e8df7 (diff)
lib.lists.mutuallyExclusive: add function
-rw-r--r--lib/lists.nix8
-rw-r--r--pkgs/stdenv/generic/default.nix7
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/lists.nix b/lib/lists.nix
index a04b1b278935..6a8fd8a18408 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -477,4 +477,12 @@ rec {
*/
subtractLists = e: filter (x: !(elem x e));
+ /* Test if two lists have no common element.
+ It should be slightly more efficient than (intersectLists a b == [])
+ */
+ mutuallyExclusive = a: b:
+ (builtins.length a) == 0 ||
+ (!(builtins.elem (builtins.head a) b) &&
+ mutuallyExclusive (builtins.tail a) b);
+
}
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 065f4fb508de..690b917b3762 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -45,13 +45,8 @@ let
throw ''‘${showLicense license}’ is not an attribute of lib.licenses''
) list;
- mutuallyExclusive = a: b:
- (builtins.length a) == 0 ||
- (!(builtins.elem (builtins.head a) b) &&
- mutuallyExclusive (builtins.tail a) b);
-
areLicenseListsValid =
- if mutuallyExclusive whitelist blacklist then
+ if lib.mutuallyExclusive whitelist blacklist then
assert onlyLicenses whitelist; assert onlyLicenses blacklist; true
else
throw "whitelistedLicenses and blacklistedLicenses are not mutually exclusive.";