Commit a178fd8c authored by Yuriy Taraday's avatar Yuriy Taraday
Browse files

stdenv: Remove all null values from meta.identifiers

nix-env writes a warning for each derivation that has null in its meta
values, so fields without known values are removed from the result.

Fixes issue raised by @K900 in https://github.com/NixOS/nixpkgs/pull/409797#issuecomment-3238995897
parent dd122905
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -577,7 +577,12 @@ let
      validYes;

  # Helper functions and declarations to handle identifiers, extracted to reduce allocations
  hasAllCPEParts = cpeParts: !any isNull (attrValues cpeParts);
  hasAllCPEParts =
    cpeParts:
    let
      values = attrValues cpeParts;
    in
    (length values == 11) && !any isNull values;
  makeCPE =
    cpeParts:
    "cpe:2.3:${cpeParts.part}:${cpeParts.vendor}:${cpeParts.product}:${cpeParts.version}:${cpeParts.update}:${cpeParts.edition}:${cpeParts.sw_edition}:${cpeParts.target_sw}:${cpeParts.target_hw}:${cpeParts.language}:${cpeParts.other}";
@@ -655,12 +660,14 @@ let

      identifiers =
        let
          # nix-env writes a warning for each derivation that has null in its meta values, so
          # fields without known values are removed from the result
          defaultCPEParts = {
            part = "a";
            vendor = null;
            product = attrs.pname or null;
            version = null;
            update = null;
            #vendor = null;
            ${if attrs ? pname then "product" else null} = attrs.pname;
            #version = null;
            #update = null;
            edition = "*";
            sw_edition = "*";
            target_sw = "*";
@@ -691,7 +698,10 @@ let
                  cpe = (makeCPE guessedParts);
                }
              ) possibleCPEPartsFuns;
          v1 = { inherit cpeParts cpe possibleCPEs; };
          v1 = {
            inherit cpeParts possibleCPEs;
            ${if cpe != null then "cpe" else null} = cpe;
          };
        in
        v1
        // {