stdenv/check-meta: verify that licenses aren't derivations
Among other things, "zlib" is a license, and it's difficult to debug the eval errors that occur when that derivation gets added to meta.licenses.
This commit is contained in:
@@ -16,12 +16,10 @@ let
|
||||
filter
|
||||
findFirst
|
||||
getName
|
||||
isDerivation
|
||||
length
|
||||
concatMap
|
||||
mutuallyExclusive
|
||||
optional
|
||||
optionalString
|
||||
isAttrs
|
||||
isString
|
||||
warn
|
||||
@@ -308,15 +306,17 @@ let
|
||||
union
|
||||
int
|
||||
attrs
|
||||
attrsOf
|
||||
any
|
||||
listOf
|
||||
bool
|
||||
record
|
||||
intersection
|
||||
not
|
||||
derivation
|
||||
;
|
||||
platforms = listOf (union [
|
||||
str
|
||||
(attrsOf any)
|
||||
attrs
|
||||
]); # see lib.meta.platformMatch
|
||||
in
|
||||
record {
|
||||
@@ -338,7 +338,10 @@ let
|
||||
let
|
||||
# TODO disallow `str` licenses, use a module
|
||||
licenseType = union [
|
||||
(attrsOf any)
|
||||
(intersection [
|
||||
attrs
|
||||
(not derivation)
|
||||
])
|
||||
str
|
||||
];
|
||||
in
|
||||
@@ -347,9 +350,9 @@ let
|
||||
licenseType
|
||||
];
|
||||
sourceProvenance = listOf attrs;
|
||||
maintainers = listOf (attrsOf any); # TODO use the maintainer type from lib/tests/maintainer-module.nix
|
||||
nonTeamMaintainers = listOf (attrsOf any); # TODO use the maintainer type from lib/tests/maintainer-module.nix
|
||||
teams = listOf (attrsOf any); # TODO similar to maintainers, use a teams type
|
||||
maintainers = listOf attrs; # TODO use the maintainer type from lib/tests/maintainer-module.nix
|
||||
nonTeamMaintainers = listOf attrs; # TODO use the maintainer type from lib/tests/maintainer-module.nix
|
||||
teams = listOf attrs; # TODO similar to maintainers, use a teams type
|
||||
priority = int;
|
||||
pkgConfigModules = listOf str;
|
||||
inherit platforms;
|
||||
|
||||
@@ -10,6 +10,7 @@ let
|
||||
isInt
|
||||
isAttrs
|
||||
isList
|
||||
isDerivation
|
||||
all
|
||||
any
|
||||
attrNames
|
||||
@@ -103,6 +104,11 @@ lib.fix (self: {
|
||||
) (attrNames attrs);
|
||||
};
|
||||
|
||||
derivation = {
|
||||
name = "derivation";
|
||||
verify = isDerivation;
|
||||
};
|
||||
|
||||
listOf =
|
||||
t:
|
||||
assert isTypeDef t;
|
||||
@@ -141,6 +147,29 @@ lib.fix (self: {
|
||||
verify = v: any (func: func v) funcs;
|
||||
};
|
||||
|
||||
intersection =
|
||||
types:
|
||||
assert all isTypeDef types;
|
||||
let
|
||||
# Store a list of functions so we don't have to pay the cost of attrset lookups at runtime.
|
||||
funcs = map (t: t.verify) types;
|
||||
in
|
||||
{
|
||||
name = "intersection<${concatStringsSep "," (map (t: t.name) types)}>";
|
||||
verify = v: all (func: func v) funcs;
|
||||
};
|
||||
|
||||
not =
|
||||
t:
|
||||
assert isTypeDef t;
|
||||
let
|
||||
inherit (t) verify;
|
||||
in
|
||||
{
|
||||
name = "not<${t.name}>";
|
||||
verify = v: !(verify v);
|
||||
};
|
||||
|
||||
enum =
|
||||
values:
|
||||
assert isList values && all isString values;
|
||||
|
||||
Reference in New Issue
Block a user