Skip to content

Regression on the use of lib.licensesSpdx #707

@kleinreact

Description

@kleinreact

We encountered a regression with the update of 7a5af01 being part of v2.21.0, which already has landed in nixpkgs.

With that update building one of our packages fails due to the license not being available in lib.licensesSpdx:

error:
       … while calling the 'derivationStrict' builtin
         at «nix-internal»/derivation-internal.nix:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'GHC-9.10.3'
         whose name attribute is located at «github:NixOS/nixpkgs/a07d4ce6bee67d7c838a8a5796e75dff9caa21ef?narHash=sha256-hQ284SkIeNaeyud%2BLS0WVLX%2BWL2rxcVZLFEaK0e03zg%3D»/pkgs/stdenv/generic/make-derivation.nix:536:13

       … while evaluating attribute 'NIX_GHC' of derivation 'GHC-9.10.3'

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute '"CERN-OHL-P-2.0"' missing
       at /nix/store/wh3jjprhaidd3znfnjmjvj1q60831zk1-cabal2nix-clash-crypto/default.nix:37:13:
           36|   description = "Cryptographic hardware in Clash";
           37|   license = lib.licensesSpdx."CERN-OHL-P-2.0";
             |             ^
           38| }

The following patch successfully works around the issue and highlights the underlying problem here: the license we use has a proper LicenseId, but is not part of lib.licensesSpdx. This breaks the assumption of 7a5af01 that every LicenseId also has a corresponding counterpart in lib.licensesSpdx.

--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
@@ -53,6 +53,7 @@ fromSPDXLicense (SPDX.License expr) =
     SPDX.ELicense simpl Nothing ->
       -- Not handled: license exceptions
       case simpl of
+        SPDX.ELicenseId SPDX.CERN_OHL_P_2_0 -> Unknown (Just $ prettyShow expr)
         SPDX.ELicenseId lid -> Known ("lib.licensesSpdx.\"" ++ prettyShow lid ++ "\"")
         _ ->
           -- Not handed: the '+' suffix and user-defined licences references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions