emacsPackages: don't set attributes to null

Depending on the version of the package from MELPA, nixpkgs can set
attributes like `preBuild` or `patches` to `null`. `mkDerivation`
filters out `null`, so this has the desirable effect of not
unnecessarily changing the actual derivation. But it is inconvenient
when using `overrideAttrs`: it breaks the common pattern of
`(previousAttrs.preBuild or "") + ''...''` (also used elsewhere in the
files this commit changes), which will fail to coerce `null` to a string
or list to append to.

Fix this everywhere attributes are set to null, by defaulting to `""` or
`[ ]` instead.

We cannot set the attribute conditionally, because the attributes names
returned by `overrideAttrs` cannot depend on `finalAttrs` (only the
values can).

This changes some helpers that are (indirectly) used by several
packages, but that part of the change is effectively a noop, because the
attributes involved are always set (either by the helper or on the
original derivation).
This commit is contained in:
Marien Zwart
2025-10-19 15:50:50 +11:00
parent 0bd2e2737c
commit 17cb17c700
3 changed files with 11 additions and 11 deletions
@@ -116,7 +116,7 @@ in
})
]
else
previousAttrs.patches or null;
previousAttrs.patches or [ ];
preBuild =
if applyOrgRoamMissingPatch then
previousAttrs.preBuild or ""
@@ -129,7 +129,7 @@ in
popd
''
else
previousAttrs.preBuild or null;
previousAttrs.preBuild or "";
}
);
@@ -18,7 +18,7 @@ rec {
if predicate finalAttrs previousAttrs then
previousAttrs.packageRequires or [ ] ++ packageRequires
else
previousAttrs.packageRequires or null;
previousAttrs.packageRequires or [ ];
}
);
@@ -89,7 +89,7 @@ rec {
if predicate finalAttrs previousAttrs then
previousAttrs.nativeBuildInputs or [ ] ++ [ pkgs.writableTmpDirAsHomeHook ]
else
previousAttrs.nativeBuildInputs or null;
previousAttrs.nativeBuildInputs or [ ];
}
);
}
@@ -830,7 +830,7 @@ let
rm --recursive --verbose etc/elisp/screenshot
''
else
previousAttrs.preBuild or null;
previousAttrs.preBuild or "";
}
);
@@ -991,7 +991,7 @@ let
})
]
else
previousAttrs.patches or null;
previousAttrs.patches or [ ];
}
)
);
@@ -1055,7 +1055,7 @@ let
''
+ previousAttrs.preBuild or ""
else
previousAttrs.preBuild or null;
previousAttrs.preBuild or "";
}
);
@@ -1221,7 +1221,7 @@ let
rm --verbose packages/javascript/test-suppport.el
''
else
previousAttrs.preBuild or null;
previousAttrs.preBuild or "";
}
);
@@ -1392,7 +1392,7 @@ let
})
]
else
previousAttrs.patches or null;
previousAttrs.patches or [ ];
}
);
@@ -1543,7 +1543,7 @@ let
})
]
else
previousAttrs.patches or null;
previousAttrs.patches or [ ];
}
);
@@ -1561,7 +1561,7 @@ let
''
+ previousAttrs.preBuild or ""
else
previousAttrs.preBuild or null;
previousAttrs.preBuild or "";
}
);