Merge pull request #49398 from Synthetica9/implement-rfc0035
Implement rfc0035: default `name` from `pname`
This commit is contained in:
commit
3fc7d5eb83
@ -12,7 +12,9 @@ rec {
|
|||||||
# * https://nixos.org/nix/manual/#ssec-derivation
|
# * https://nixos.org/nix/manual/#ssec-derivation
|
||||||
# Explanation about derivations in general
|
# Explanation about derivations in general
|
||||||
mkDerivation =
|
mkDerivation =
|
||||||
{ name ? ""
|
{ name ? if attrs ? pname && attrs ? version
|
||||||
|
then "${attrs.pname}-${attrs.version}"
|
||||||
|
else ""
|
||||||
|
|
||||||
# These types of dependencies are all exhaustively documented in
|
# These types of dependencies are all exhaustively documented in
|
||||||
# the "Specifying Dependencies" section of the "Standard
|
# the "Specifying Dependencies" section of the "Standard
|
||||||
@ -65,6 +67,8 @@ rec {
|
|||||||
, pos ? # position used in error messages and for meta.position
|
, pos ? # position used in error messages and for meta.position
|
||||||
(if attrs.meta.description or null != null
|
(if attrs.meta.description or null != null
|
||||||
then builtins.unsafeGetAttrPos "description" attrs.meta
|
then builtins.unsafeGetAttrPos "description" attrs.meta
|
||||||
|
else if attrs.version or null != null
|
||||||
|
then builtins.unsafeGetAttrPos "version" attrs
|
||||||
else builtins.unsafeGetAttrPos "name" attrs)
|
else builtins.unsafeGetAttrPos "name" attrs)
|
||||||
, separateDebugInfo ? false
|
, separateDebugInfo ? false
|
||||||
, outputs ? [ "out" ]
|
, outputs ? [ "out" ]
|
||||||
@ -78,6 +82,13 @@ rec {
|
|||||||
|
|
||||||
, ... } @ attrs:
|
, ... } @ attrs:
|
||||||
|
|
||||||
|
# Check that the name is consistent with pname and version:
|
||||||
|
assert lib.assertMsg
|
||||||
|
(lib.lists.all (name: builtins.hasAttr name attrs) ["name" "pname" "version"]
|
||||||
|
-> lib.strings.hasSuffix "${attrs.pname}-${attrs.version}" attrs.name)
|
||||||
|
("mkDerivation: `name` (\"${attrs.name}\") must be consistent " +
|
||||||
|
"with `pname-version` \"${attrs.pname}-${attrs.version}\"");
|
||||||
|
|
||||||
let
|
let
|
||||||
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
|
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
|
||||||
# no package has `doCheck = true`.
|
# no package has `doCheck = true`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user