lib.meta.getLicenseBySpdxId: set spdxId in default value

Nixpkgs does not contain an entry in lib.licenses for every SPDX license,
so it is expected that a valid SPDX id would yield no proper result from
getLicenseFromSpdxId. Hence, we should set spdxId in the default value.

Users that think their SPDX ID may be invalid should rather use
getLicenseFromSpdxIdOr.
This commit is contained in:
sternenseemann
2026-03-17 16:14:31 +01:00
parent 661b0d8ec7
commit 666476ff53

View File

@@ -434,8 +434,9 @@ rec {
getLicenseFromSpdxId =
licstr:
getLicenseFromSpdxIdOr licstr (
lib.warn "getLicenseFromSpdxId: No license matches the given SPDX ID: ${licstr}" {
lib.warn "getLicenseFromSpdxId: No license with the given SPDX ID found: ${licstr}" {
shortName = licstr;
spdxId = licstr;
}
);