From 4e2614fc0709ff77e40a8f39e2744239ee371826 Mon Sep 17 00:00:00 2001 From: h0nIg Date: Sun, 29 Jun 2025 21:44:02 +0200 Subject: [PATCH 1/7] stdenv: pURL implementation --- doc/redirects.json | 9 ++++ doc/release-notes/rl-2511.section.md | 2 + doc/stdenv/meta.chapter.md | 15 +++++++ pkgs/build-support/fetchgit/default.nix | 10 ++++- pkgs/build-support/fetchgithub/default.nix | 43 +++++++++++++++---- pkgs/build-support/fetchpypi/default.nix | 16 ++++++- .../python/mk-python-derivation.nix | 1 + pkgs/development/ruby-modules/gem/default.nix | 10 +++++ pkgs/stdenv/generic/check-meta.nix | 17 +++++++- 9 files changed, 111 insertions(+), 12 deletions(-) diff --git a/doc/redirects.json b/doc/redirects.json index 1230b6460b548..0ab407db19f37 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -231,6 +231,9 @@ "sec-meta-identifiers-cpe": [ "index.html#sec-meta-identifiers-cpe" ], + "sec-meta-identifiers-purl": [ + "index.html#sec-meta-identifiers-purl" + ], "sec-modify-via-packageOverrides": [ "index.html#sec-modify-via-packageOverrides" ], @@ -643,6 +646,12 @@ "var-meta-identifiers-possibleCPEs": [ "index.html#var-meta-identifiers-possibleCPEs" ], + "var-meta-identifiers-purl": [ + "index.html#var-meta-identifiers-purl" + ], + "var-meta-identifiers-purlParts": [ + "index.html#var-meta-identifiers-purlParts" + ], "var-meta-teams": [ "index.html#var-meta-teams" ], diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 018554743449d..6d5cf577fb72a 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -176,6 +176,8 @@ +- Metadata identifier pURL (https://github.com/package-url/purl-spec) has been added, which enables a SBOM generation. Maintainers are urged to check their `drv.meta.identifiers.v1.purl` for completeness. + - Added `rewriteURL` attribute to the nixpkgs `config`, to allow for rewriting the URLs downloaded by `fetchurl`. - The `dockerTools.streamLayeredImage` builder now uses a better algorithm for generating layered docker images, such that much more sharing is possible when the number of store paths exceeds the layer limit. It gives each of the largest store paths its own layer and adds dependencies to those layers when they aren't used elsewhere. diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index 947009869ff15..606d607e04d13 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -319,3 +319,18 @@ A readonly attribute that concatenates all CPE parts in one string. #### `meta.identifiers.possibleCPEs` {#var-meta-identifiers-possibleCPEs} A readonly attribute containing the list of guesses for what CPE for this package can look like. It includes all variants of version handling mentioned above. Each item is an attrset with attributes `cpeParts` and `cpe` for each guess. + +### Package URL {#sec-meta-identifiers-purl} + +[Package URL](https://github.com/package-url/purl-spec) (pURL) is a specification to reliably identify and locate software packages. + +#### `meta.identifiers.purlParts` {#var-meta-identifiers-purlParts} + +This attribute contains an attribute set of all parts of the pURL for this package. + +* `type` mandatory [type](https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/docs/standard/summary.md) which needs to be provided +* `spec` specify the pURL in accordance with the [purl-spec](https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/purl-specification.md) + +#### `meta.identifiers.purl` {#var-meta-identifiers-purl} + +A readonly attribute which is built based on purlParts. diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index b2f5f15a309da..ed9daa7ff525c 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -185,7 +185,15 @@ lib.makeOverridable ( "FETCHGIT_HTTP_PROXIES" ]; - inherit preferLocalBuild meta allowedRequisites; + inherit preferLocalBuild allowedRequisites; + + meta = meta // { + identifiers.purlParts = { + type = "generic"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/generic-definition.md + spec = "${name}?vcs_url=${url}@${(lib.revOrTag rev tag)}"; + }; + }; passthru = { gitRepoUrl = url; diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index 2b3ab060418af..fbbf1dd153b19 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -43,14 +43,36 @@ lib.makeOverridable ( ); baseUrl = "https://${githubBase}/${owner}/${repo}"; newMeta = - meta - // { - homepage = meta.homepage or baseUrl; - } - // lib.optionalAttrs (position != null) { - # to indicate where derivation originates, similar to make-derivation.nix's mkDerivation - position = "${position.file}:${toString position.line}"; - }; + lib.recursiveUpdate + ( + meta + // { + homepage = meta.homepage or baseUrl; + } + // lib.optionalAttrs (position != null) { + # to indicate where derivation originates, similar to make-derivation.nix's mkDerivation + position = "${position.file}:${toString position.line}"; + } + ) + + ( + { + identifiers.purlParts = + if githubBase == "github.com" then + { + type = "github"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/github-definition.md + spec = "${owner}/${repo}@${(lib.revOrTag rev tag)}"; + } + else + { + type = "generic"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/generic-definition.md + spec = "${repo}?vcs_url=https://${githubBase}/${owner}/${repo}@${(lib.revOrTag rev tag)}"; + }; + } + ); + passthruAttrs = removeAttrs args [ "owner" "repo" @@ -153,12 +175,15 @@ lib.makeOverridable ( // passthruAttrs // { inherit name; + } + # fetchurl / fetchzip is not a function, but fetchurlBoot is - ensure that the parameter is accepted and passed through + // lib.optionalAttrs (!builtins.isFunction fetcher || (builtins.functionArgs fetcher) ? meta) { + meta = newMeta; }; in fetcher fetcherArgs // { - meta = newMeta; inherit owner repo tag; rev = revWithTag; } diff --git a/pkgs/build-support/fetchpypi/default.nix b/pkgs/build-support/fetchpypi/default.nix index cb7e443ab7eff..7510582ccf58b 100644 --- a/pkgs/build-support/fetchpypi/default.nix +++ b/pkgs/build-support/fetchpypi/default.nix @@ -51,6 +51,8 @@ makeOverridable ( format ? "setuptools", sha256 ? "", hash ? "", + pname, + version, ... }@attrs: let @@ -60,8 +62,20 @@ makeOverridable ( "hash" ] ); + meta = { + identifiers.purlParts = { + type = "pypi"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/pypi-definition.md + spec = "${pname}@${version}"; + }; + }; in fetchurl { - inherit url sha256 hash; + inherit + url + sha256 + hash + meta + ; } ) diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index eb8e76101c492..c7ff2f0dce700 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -416,6 +416,7 @@ let # default to python's platforms platforms = python.meta.platforms; isBuildPythonPackage = python.meta.platforms; + identifiers.purlParts = attrs.src.meta.identifiers.purlParts or { }; } // meta; } diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index 0e3c1c4187f2a..d8b91063ef51d 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -300,6 +300,16 @@ lib.makeOverridable ( platforms = ruby.meta.platforms; mainProgram = gemName; } + // (lib.optionalAttrs (type == "gem") { + identifiers.purlParts = { + type = "gem"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/gem-definition.md + spec = "${gemName}@${version}?platform=${platform}"; + }; + }) + // (lib.optionalAttrs (type == "git") { + identifiers.purlParts = src.meta.identifiers.purlParts or { }; + }) // meta; } ) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index d8f519b0f1851..4dbc7dd0520a5 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -605,6 +605,12 @@ let }) tryCPEPatchVersionInUpdateWithVendor ]; + hasAllPURLParts = + purlParts: + let + values = attrValues purlParts; + in + (length values == 2) && !any isNull values; # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not @@ -710,9 +716,18 @@ let cpe = makeCPE guessedParts; } ) possibleCPEPartsFuns; + + purlParts = attrs.meta.identifiers.purlParts or { }; + purl = if hasAllPURLParts purlParts then "pkg:${purlParts.type}/${purlParts.spec}" else null; + v1 = { - inherit cpeParts possibleCPEs; + inherit + cpeParts + possibleCPEs + purlParts + ; ${if cpe != null then "cpe" else null} = cpe; + ${if purl != null then "purl" else null} = purl; }; in v1 From 0a69474ed34ef6a4e82804b4b2d844deb126a1ab Mon Sep 17 00:00:00 2001 From: Hans Joachim Kliemeck Date: Sat, 20 Sep 2025 18:22:53 +0200 Subject: [PATCH 2/7] stdenv: pURL github speed optimization --- pkgs/build-support/fetchgithub/default.nix | 50 +++++++++------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index fbbf1dd153b19..caf82cf7de533 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -43,35 +43,27 @@ lib.makeOverridable ( ); baseUrl = "https://${githubBase}/${owner}/${repo}"; newMeta = - lib.recursiveUpdate - ( - meta - // { - homepage = meta.homepage or baseUrl; - } - // lib.optionalAttrs (position != null) { - # to indicate where derivation originates, similar to make-derivation.nix's mkDerivation - position = "${position.file}:${toString position.line}"; - } - ) - - ( - { - identifiers.purlParts = - if githubBase == "github.com" then - { - type = "github"; - # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/github-definition.md - spec = "${owner}/${repo}@${(lib.revOrTag rev tag)}"; - } - else - { - type = "generic"; - # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/generic-definition.md - spec = "${repo}?vcs_url=https://${githubBase}/${owner}/${repo}@${(lib.revOrTag rev tag)}"; - }; - } - ); + meta + // { + homepage = meta.homepage or baseUrl; + identifiers.purlParts = + if githubBase == "github.com" then + { + type = "github"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/github-definition.md + spec = "${owner}/${repo}@${(lib.revOrTag rev tag)}"; + } + else + { + type = "generic"; + # https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/generic-definition.md + spec = "${repo}?vcs_url=https://${githubBase}/${owner}/${repo}@${(lib.revOrTag rev tag)}"; + }; + } + // lib.optionalAttrs (position != null) { + # to indicate where derivation originates, similar to make-derivation.nix's mkDerivation + position = "${position.file}:${toString position.line}"; + }; passthruAttrs = removeAttrs args [ "owner" From 2e46d00d76d3c9690e9713a9c2686c328e3779da Mon Sep 17 00:00:00 2001 From: Hans Joachim Kliemeck Date: Sat, 20 Sep 2025 18:24:18 +0200 Subject: [PATCH 3/7] stdenv: pURL docu enhancements & list interface --- doc/redirects.json | 3 +++ doc/release-notes/rl-2511.section.md | 2 +- doc/stdenv/meta.chapter.md | 8 ++++++-- pkgs/stdenv/generic/check-meta.nix | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/redirects.json b/doc/redirects.json index 0ab407db19f37..72b46ad9aba20 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -652,6 +652,9 @@ "var-meta-identifiers-purlParts": [ "index.html#var-meta-identifiers-purlParts" ], + "var-meta-identifiers-purls": [ + "index.html#var-meta-identifiers-purls" + ], "var-meta-teams": [ "index.html#var-meta-teams" ], diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 6d5cf577fb72a..9f59e6f92ffe2 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -176,7 +176,7 @@ -- Metadata identifier pURL (https://github.com/package-url/purl-spec) has been added, which enables a SBOM generation. Maintainers are urged to check their `drv.meta.identifiers.v1.purl` for completeness. +- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and derivations for Perl, Python and Ruby derivations have been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. - Added `rewriteURL` attribute to the nixpkgs `config`, to allow for rewriting the URLs downloaded by `fetchurl`. diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index 606d607e04d13..94352e00d935a 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -322,7 +322,7 @@ A readonly attribute containing the list of guesses for what CPE for this packag ### Package URL {#sec-meta-identifiers-purl} -[Package URL](https://github.com/package-url/purl-spec) (pURL) is a specification to reliably identify and locate software packages. +[Package URL](https://github.com/package-url/purl-spec) (pURL) is a specification to reliably identify and locate software packages. Through identification of software packages, additional (non-major) use cases are e.g. software license cross-verification via third party databases or initial vulnerability response management. Package URL's default to the mkDerivation.src, as the original consumed software package is the single point of truth. #### `meta.identifiers.purlParts` {#var-meta-identifiers-purlParts} @@ -333,4 +333,8 @@ This attribute contains an attribute set of all parts of the pURL for this packa #### `meta.identifiers.purl` {#var-meta-identifiers-purl} -A readonly attribute which is built based on purlParts. +A readonly attribute which is built based on purlParts. It is the main identifier, consumers should consider using the pURL's list interface to be prepared for edge cases. + +#### `meta.identifiers.purls` {#var-meta-identifiers-purls} + +A readonly attribute list which defaults to a single element equal to the main pURL. It provides an interface for additional identifiers of mkDerivation.src and / or vendored dependencies inside mkDerivation.src, which maintainers can conciously decide to use on top. Identifiers different to the default src identifier are not recommended by default as they might cause maintenance overhead or may diverge (e.g. differences between source distribution pkg:github and binary distribution like pkg:pypi). diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 4dbc7dd0520a5..231867cd04cdf 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -719,12 +719,14 @@ let purlParts = attrs.meta.identifiers.purlParts or { }; purl = if hasAllPURLParts purlParts then "pkg:${purlParts.type}/${purlParts.spec}" else null; + purls = optional (purl != null) purl; v1 = { inherit cpeParts possibleCPEs purlParts + purls ; ${if cpe != null then "cpe" else null} = cpe; ${if purl != null then "purl" else null} = purl; From c78e6a235962eb272981ea6b16939034c0fde575 Mon Sep 17 00:00:00 2001 From: Hans Joachim Kliemeck Date: Sat, 20 Sep 2025 18:23:32 +0200 Subject: [PATCH 4/7] stdenv: pURL golang support --- doc/release-notes/rl-2511.section.md | 2 +- pkgs/build-support/go/module.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 9f59e6f92ffe2..44099ea8c8b84 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -176,7 +176,7 @@ -- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and derivations for Perl, Python and Ruby derivations have been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. +- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and derivations for Perl, Python, Ruby and Golang derivations have been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. - Added `rewriteURL` attribute to the nixpkgs `config`, to allow for rewriting the URLs downloaded by `fetchurl`. diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 00ba03533e345..7759fbd4b8972 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -424,6 +424,7 @@ lib.extendMkDerivation { meta = { # Add default meta information. platforms = go.meta.platforms or lib.platforms.all; + identifiers.purlParts = finalAttrs.src.meta.identifiers.purlParts or { }; } // meta; }; From 64a6ca1114355caca991817cba83c4beb18136e2 Mon Sep 17 00:00:00 2001 From: Hans Joachim Kliemeck Date: Sat, 20 Sep 2025 22:53:24 +0200 Subject: [PATCH 5/7] stdenv: pURL speed optimization --- pkgs/build-support/go/module.nix | 7 ++++++- .../interpreters/python/mk-python-derivation.nix | 7 ++++++- pkgs/development/ruby-modules/gem/default.nix | 6 +++++- pkgs/stdenv/generic/check-meta.nix | 16 ++++++---------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 7759fbd4b8972..2ed86cb759c7b 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -424,7 +424,12 @@ lib.extendMkDerivation { meta = { # Add default meta information. platforms = go.meta.platforms or lib.platforms.all; - identifiers.purlParts = finalAttrs.src.meta.identifiers.purlParts or { }; + identifiers = { + ${if (finalAttrs.src.meta.identifiers.purl or null) != null then "purl" else null} = + finalAttrs.src.meta.identifiers.purl; + ${if (finalAttrs.src.meta.identifiers.purls or null) != null then "purls" else null} = + finalAttrs.src.meta.identifiers.purls; + }; } // meta; }; diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index c7ff2f0dce700..c153d2c01fc02 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -416,7 +416,12 @@ let # default to python's platforms platforms = python.meta.platforms; isBuildPythonPackage = python.meta.platforms; - identifiers.purlParts = attrs.src.meta.identifiers.purlParts or { }; + identifiers = { + ${if (attrs.src.meta.identifiers.purl or null) != null then "purl" else null} = + attrs.src.meta.identifiers.purl; + ${if (attrs.src.meta.identifiers.purls or null) != null then "purls" else null} = + attrs.src.meta.identifiers.purls; + }; } // meta; } diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index d8b91063ef51d..ec4777d1ee502 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -308,7 +308,11 @@ lib.makeOverridable ( }; }) // (lib.optionalAttrs (type == "git") { - identifiers.purlParts = src.meta.identifiers.purlParts or { }; + identifiers = { + ${if (src.meta.identifiers.purl or null) != null then "purl" else null} = src.meta.identifiers.purl; + ${if (src.meta.identifiers.purls or null) != null then "purls" else null} = + src.meta.identifiers.purls; + }; }) // meta; } diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 231867cd04cdf..cd690197939b3 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -605,12 +605,6 @@ let }) tryCPEPatchVersionInUpdateWithVendor ]; - hasAllPURLParts = - purlParts: - let - values = attrValues purlParts; - in - (length values == 2) && !any isNull values; # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not @@ -718,14 +712,16 @@ let ) possibleCPEPartsFuns; purlParts = attrs.meta.identifiers.purlParts or { }; - purl = if hasAllPURLParts purlParts then "pkg:${purlParts.type}/${purlParts.spec}" else null; - purls = optional (purl != null) purl; + purl = + attrs.meta.identifiers.purl or ( + if purlParts ? type && purlParts ? spec then "pkg:${purlParts.type}/${purlParts.spec}" else null + ); + purls = attrs.meta.identifiers.purls or (optional (purl != null) purl); v1 = { inherit cpeParts possibleCPEs - purlParts purls ; ${if cpe != null then "cpe" else null} = cpe; @@ -734,7 +730,7 @@ let in v1 // { - inherit v1; + inherit v1 purlParts; }; # Expose the result of the checks for everyone to see. From 22dbee80107516b858abd3d7a45c149a316a78d8 Mon Sep 17 00:00:00 2001 From: Hans Joachim Kliemeck Date: Sun, 21 Sep 2025 12:49:31 +0200 Subject: [PATCH 6/7] stdenv: pURL non-default adjustment examples --- doc/release-notes/rl-2511.section.md | 2 +- pkgs/by-name/jq/jq/package.nix | 4 ++++ pkgs/by-name/po/popt/package.nix | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 44099ea8c8b84..1e88dfe174a40 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -176,7 +176,7 @@ -- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and derivations for Perl, Python, Ruby and Golang derivations have been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. +- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and derivations for Perl, Python, Ruby and Golang derivations have been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers of derivations using the adopted fetchers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. Maintainers using fetchurl for `drv.src` are urged to adopt their `drv.meta.identifiers.purlParts` for proper identification. - Added `rewriteURL` attribute to the nixpkgs `config`, to allow for rewriting the URLs downloaded by `fetchurl`. diff --git a/pkgs/by-name/jq/jq/package.nix b/pkgs/by-name/jq/jq/package.nix index b2a0941a79fe4..5ad75de67faf0 100644 --- a/pkgs/by-name/jq/jq/package.nix +++ b/pkgs/by-name/jq/jq/package.nix @@ -134,5 +134,9 @@ stdenv.mkDerivation (finalAttrs: { ]; platforms = lib.platforms.unix; mainProgram = "jq"; + identifiers.purlParts = { + type = "github"; + spec = "jqlang/jq@jq-${finalAttrs.version}"; + }; }; }) diff --git a/pkgs/by-name/po/popt/package.nix b/pkgs/by-name/po/popt/package.nix index eb9e4f3685ed4..c40e17228f54a 100644 --- a/pkgs/by-name/po/popt/package.nix +++ b/pkgs/by-name/po/popt/package.nix @@ -49,5 +49,9 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ qyliss ]; license = licenses.mit; platforms = platforms.unix; + identifiers.purlParts = { + type = "github"; + spec = "rpm-software-management/popt@popt-${version}-release"; + }; }; } From a62b26b5f0d752e82f8a5ed07bf1667726c29386 Mon Sep 17 00:00:00 2001 From: Hans Joachim Kliemeck Date: Sun, 21 Sep 2025 14:56:06 +0200 Subject: [PATCH 7/7] stdenv: pURL perl fix perl -0777 -i.original -pe 's|(fetchurl {\n url = "mirror://cpan/authors/id/./.{2}/([^/]*)/(.*?))\n };\n };\n|\1\n identifiers.purlParts = {\n type = "cpan";\n spec = "\2/\${pname}@\${version}";\n };\n };\n };\n|igs' pkgs/top-level/perl-packages.nix sed -i 's/buildPerlPackage {/buildPerlPackage rec {/g' pkgs/top-level/perl-packages.nix --- maintainers/scripts/nix-generate-from-cpan.pl | 6 +- pkgs/top-level/perl-packages.nix | 11258 +++++++++++++--- 2 files changed, 9396 insertions(+), 1868 deletions(-) diff --git a/maintainers/scripts/nix-generate-from-cpan.pl b/maintainers/scripts/nix-generate-from-cpan.pl index 6754f79009ec9..e9839931ff0db 100755 --- a/maintainers/scripts/nix-generate-from-cpan.pl +++ b/maintainers/scripts/nix-generate-from-cpan.pl @@ -438,7 +438,7 @@ sub sha256_to_sri { print STDERR "===\n"; print <maintainer} ]; EOF print <