summary refs log tree commit diff
path: root/pkgs/stdenv/generic
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2023-02-18 19:45:18 +0100
committerSandro Jäckel <sandro.jaeckel@gmail.com>2023-04-12 22:08:36 +0200
commitb0ee79f9fdddb40a2bceb34c2578b349aa09425e (patch)
tree02f611927d4bb72ff6a5e5503bf5774056a45913 /pkgs/stdenv/generic
parent5de1815be9e61eb3c0cef2517d7fe2b1f6a7b75d (diff)
downloadnixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.tar
nixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.tar.gz
nixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.tar.bz2
nixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.tar.lz
nixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.tar.xz
nixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.tar.zst
nixpkgs-b0ee79f9fdddb40a2bceb34c2578b349aa09425e.zip
mkDerivation: show meaningful error when version is set to null
instead of `Cannot coerce null to string`
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index 3d60934557c..4131067cb42 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -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;