stdenv: Package URL (PURL) metadata fields

This commit is contained in:
Hans Joachim Kliemeck
2026-03-08 21:18:51 +00:00
committed by Arnout Engelen
parent 3c74a9f084
commit 8478c2384b
10 changed files with 127 additions and 5 deletions

View File

@@ -412,6 +412,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"
],
@@ -932,6 +935,15 @@
"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-identifiers-purls": [
"index.html#var-meta-identifiers-purls"
],
"var-meta-teams": [
"index.html#var-meta-teams"
],

View File

@@ -16,7 +16,11 @@
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
- Create the first release note entry in this section!
- Package-URL (PURL, https://github.com/package-url/purl-spec) metadata identifier has been added for `fetchgit`, `fetchpypi` and `fetchFromGithub` fetchers.
`mkDerivation` has been adjusted to reuse this information.
Package-URLs allow reliably identifying and locating software packages.
Maintainers of derivations using the adapted 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 adapt their `drv.meta.identifiers.purlParts` for proper identification.
## Nixpkgs Library {#sec-nixpkgs-release-26.11-lib}

View File

@@ -334,3 +334,30 @@ 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.
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-URLs shall default to the `mkDerivation.src`, as the original consumed software package is the single source of truth.
#### `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}
An extendable attribute which is built based on `purlParts`.
This is the main identifier of the software package.
For handling edge cases, consider using the list interface [`meta.identifiers.purls`](#var-meta-identifiers-purls).
#### `meta.identifiers.purls` {#var-meta-identifiers-purls}
An extendable list attribute which defaults to a single element equal to [`meta.identifiers.purl`](#var-meta-identifiers-purl).
It provides an interface for additional identifiers of `mkDerivation.src` or for identifiers of vendored dependencies inside `mkDerivation.src`, which maintainers may carefully consider to specify as well.
Additional identifiers are generally not recommended, as they might cause maintenance overhead or diverge.
For example, a source distribution `pkg:github` may be hard to keep correctly aligned with the corresponding binary distribution `pkg:pypi`.