summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-11-03 21:33:36 +0000
committerGitHub <noreply@github.com>2018-11-03 21:33:36 +0000
commit3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08 (patch)
tree559a62d073d05b412a611dae7094df490261feef /pkgs
parent1fddf2b68996b56804a24b67191e4d883943057d (diff)
parent1f7fc09176dc9b0260b8e2778f1e6c3139eae6a9 (diff)
downloadnixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.tar
nixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.tar.gz
nixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.tar.bz2
nixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.tar.lz
nixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.tar.xz
nixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.tar.zst
nixlib-3fc7d5eb83804e10ae55b1ae9b102f88b1ea2b08.zip
Merge pull request #49398 from Synthetica9/implement-rfc0035
Implement rfc0035: default `name` from `pname`
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix13
1 files changed, 12 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index e06faed30a1e..cb3731da1934 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -12,7 +12,9 @@ rec {
   # * https://nixos.org/nix/manual/#ssec-derivation
   #   Explanation about derivations in general
   mkDerivation =
-    { name ? ""
+    { name ? if attrs ? pname && attrs ? version
+        then "${attrs.pname}-${attrs.version}"
+        else ""
 
     # These types of dependencies are all exhaustively documented in
     # the "Specifying Dependencies" section of the "Standard
@@ -65,6 +67,8 @@ rec {
     , pos ? # position used in error messages and for meta.position
         (if attrs.meta.description or null != null
           then builtins.unsafeGetAttrPos "description" attrs.meta
+          else if attrs.version or null != null
+          then builtins.unsafeGetAttrPos "version" attrs
           else builtins.unsafeGetAttrPos "name" attrs)
     , separateDebugInfo ? false
     , outputs ? [ "out" ]
@@ -78,6 +82,13 @@ rec {
 
     , ... } @ 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
       # TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
       # no package has `doCheck = true`.