diff --git a/lib/default.nix b/lib/default.nix index 63a31101eee7..0ff3a3980745 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -123,7 +123,8 @@ let inherit (self.derivations) lazyDerivation optionalDrvAttr; inherit (self.meta) addMetaAttrs dontDistribute setName updateName appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio - hiPrioSet getLicenseFromSpdxId getLicenseFromSpdxIdOr getExe getExe'; + hiPrioSet licensesSpdx getLicenseFromSpdxId getLicenseFromSpdxIdOr + getExe getExe'; inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile packagesFromDirectoryRecursive; inherit (self.sources) cleanSourceFilter diff --git a/lib/meta.nix b/lib/meta.nix index ddd062f38c47..57f3a46d0698 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -7,6 +7,7 @@ let inherit (lib) matchAttrs any all isDerivation getBin assertMsg; + inherit (lib.attrsets) mapAttrs' filterAttrs; inherit (builtins) isString match typeOf; in @@ -289,7 +290,8 @@ rec { /** Mapping of SPDX ID to the attributes in lib.licenses. - For SPDX IDs, see https://spdx.org/licenses + For SPDX IDs, see https://spdx.org/licenses. + Note that some SPDX licenses might be missing. # Examples :::{.example} @@ -305,18 +307,19 @@ rec { ::: */ licensesSpdx = - lib.attrsets.mapAttrs' + mapAttrs' (_key: license: { name = license.spdxId; value = license; }) - (lib.attrsets.filterAttrs (_key: license: license ? spdxId) lib.licenses); + (filterAttrs (_key: license: license ? spdxId) lib.licenses); /** Get the corresponding attribute in lib.licenses from the SPDX ID or warn and fallback to `{ shortName = ; }`. - For SPDX IDs, see https://spdx.org/licenses + For SPDX IDs, see https://spdx.org/licenses. + Note that some SPDX licenses might be missing. # Type @@ -351,7 +354,8 @@ rec { Get the corresponding attribute in lib.licenses from the SPDX ID or fallback to the given default value. - For SPDX IDs, see https://spdx.org/licenses + For SPDX IDs, see https://spdx.org/licenses. + Note that some SPDX licenses might be missing. # Inputs