3
0
Fork 0
forked from mirrors/nixpkgs

check-meta.nix: make non-source consistent with documentation

The documentation for `meta.sourceProvenance` in
`doc/stdenv/meta.chapter.md` says: "the `meta.sourceProvenance`
attribute should be a list containing one or more value..."

Let's update check-meta.nix to require that `meta.sourceProvenance` is
a list, as the documentation says, rather than a single element.

Adding two extra keystrokes `[` and `]` when filling out this field is
an insignificant burden for package authors, and being able to assume
that the `meta.sourceProvenance` field is always a list greatly
simplifies any code that acts on the value of this field.

Since `meta.sourceProvenance` was just merged a few hours ago now is
the easiest time to fix this: nobody is using the feature yet.
This commit is contained in:
Adam Joseph 2022-05-30 10:11:09 -07:00
parent 8d6446d553
commit 607d59fa9e

View file

@ -93,14 +93,14 @@ let
hasNonSourceProvenance = attrs:
(attrs ? meta.sourceProvenance) &&
isNonSource (lib.lists.toList attrs.meta.sourceProvenance);
isNonSource attrs.meta.sourceProvenance;
# Allow granular checks to allow only some non-source-built packages
# Example:
# { pkgs, ... }:
# {
# allowNonSource = false;
# allowNonSourcePredicate = with pkgs.lib.lists; pkg: !(any (p: !p.isSource && p != lib.sourceTypes.binaryFirmware) (toList pkg.meta.sourceProvenance));
# allowNonSourcePredicate = with pkgs.lib.lists; pkg: !(any (p: !p.isSource && p != lib.sourceTypes.binaryFirmware) pkg.meta.sourceProvenance);
# }
allowNonSourcePredicate = config.allowNonSourcePredicate or (x: false);
@ -269,7 +269,7 @@ let
license = let
licenseType = either (attrsOf anything) str; # TODO disallow `str` licenses, use a module
in either licenseType (listOf licenseType);
sourceProvenance = either (listOf (attrsOf anything)) (attrsOf anything);
sourceProvenance = listOf lib.types.attrs;
maintainers = listOf (attrsOf anything); # TODO use the maintainer type from lib/tests/maintainer-module.nix
priority = int;
platforms = listOf str;