From 7883af8db434a03e90bd7850edc29059bc9cefd6 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 30 May 2022 10:11:09 -0700 Subject: [PATCH 1/2] 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. --- pkgs/stdenv/generic/check-meta.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index f9bea506af6ed..8e80baa3c3683 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -94,14 +94,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); @@ -258,7 +258,7 @@ let downloadPage = str; changelog = either (listOf str) str; license = either (listOf lib.types.attrs) (either lib.types.attrs str); - sourceProvenance = either (listOf lib.types.attrs) lib.types.attrs; + sourceProvenance = listOf lib.types.attrs; maintainers = listOf (attrsOf str); priority = int; platforms = listOf str; From d2afb5443bd0a4228f3490086fb89f727f5a6a7e Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 3 Jul 2022 11:39:04 -0700 Subject: [PATCH 2/2] hello: add invalid sourceProvenance --- pkgs/applications/misc/hello/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/misc/hello/default.nix b/pkgs/applications/misc/hello/default.nix index c82de2ae02770..cc9a03b8ac6dc 100644 --- a/pkgs/applications/misc/hello/default.nix +++ b/pkgs/applications/misc/hello/default.nix @@ -39,6 +39,7 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://www.gnu.org/software/hello/manual/"; changelog = "https://git.savannah.gnu.org/cgit/hello.git/plain/NEWS?h=v${finalAttrs.version}"; license = licenses.gpl3Plus; + sourceProvenance = lib.sourceType.fromSource; maintainers = [ maintainers.eelco ]; platforms = platforms.all; };