3
0
Fork 0
forked from mirrors/nixpkgs

mkDerivation: show meaningful error when version is set to null

instead of `Cannot coerce null to string`
This commit is contained in:
Sandro Jäckel 2023-02-18 19:45:18 +01:00
parent 5de1815be9
commit b0ee79f9fd
No known key found for this signature in database
GPG key ID: 3AF5A43A3EECC2E5

View file

@ -300,6 +300,7 @@ else let
hostSuffix = lib.optionalString
(stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix)
"-${stdenv.hostPlatform.config}";
# Disambiguate statically built packages. This was originally
# introduce as a means to prevent nix-env to get confused between
# nix and nixStatic. This should be also achieved by moving the
@ -310,7 +311,10 @@ else let
lib.strings.sanitizeDerivationName (
if attrs ? name
then attrs.name + hostSuffix
else "${attrs.pname}${staticMarker}${hostSuffix}-${attrs.version}"
else
# we cannot coerce null to a string below
assert lib.assertMsg (attrs ? version && attrs.version != null) "The version attribute cannot be null.";
"${attrs.pname}${staticMarker}${hostSuffix}-${attrs.version}"
);
}) // lib.optionalAttrs __structuredAttrs { env = checkedEnv; } // {
builder = attrs.realBuilder or stdenv.shell;