@@ -12,7 +12,9 @@ rec {
1212 # * https://nixos.org/nix/manual/#ssec-derivation
1313 # Explanation about derivations in general
1414 mkDerivation =
15− { name ? ""
15+ { name ? if attrs ? pname && attrs ? version
16+ then "${attrs.pname}-${attrs.version}"
17+ else ""
1618
1719 # These types of dependencies are all exhaustively documented in
1820 # the "Specifying Dependencies" section of the "Standard
@@ -65,6 +67,8 @@ rec {
6567 , pos ? # position used in error messages and for meta.position
6668 (if attrs.meta.description or null != null
6769 then builtins.unsafeGetAttrPos "description" attrs.meta
70+ else if attrs.version or null != null
71+ then builtins.unsafeGetAttrPos "version" attrs
6872 else builtins.unsafeGetAttrPos "name" attrs)
6973 , separateDebugInfo ? false
7074 , outputs ? [ "out" ]
@@ -78,6 +82,13 @@ rec {
7882
7983 , ... } @ attrs:
8084
85+ # Check that the name is consistent with pname and version:
86+ assert lib.assertMsg
87+ (lib.lists.all (name: builtins.hasAttr name attrs) ["name" "pname" "version"]
88+ -> lib.strings.hasSuffix "${attrs.pname}-${attrs.version}" attrs.name)
89+ ("mkDerivation: `name` (\"${attrs.name}\") must be consistent " +
90+ "with `pname-version` \"${attrs.pname}-${attrs.version}\"");
91+
8192 let
8293 # TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
8394 # no package has `doCheck = true`.