From b0ee79f9fdddb40a2bceb34c2578b349aa09425e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 18 Feb 2023 19:45:18 +0100 Subject: [PATCH 1/3] mkDerivation: show meaningful error when version is set to null instead of `Cannot coerce null to string` --- pkgs/stdenv/generic/make-derivation.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 3d60934557c6..4131067cb423 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; From a7dbdb7644ec27782b35a8dc07e3b0070c5232ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 18 Feb 2023 19:44:44 +0100 Subject: [PATCH 2/3] cc-wrapper: don't set env to null when nativeTools is used This is not allowed and fails fatal --- pkgs/build-support/cc-wrapper/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 6520c04f5e8a..c614fe0d287a 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -550,8 +550,11 @@ stdenv.mkDerivation { expandResponseParams = "${expand-response-params}/bin/expand-response-params"; shell = getBin shell + shell.shellPath or ""; gnugrep_bin = if nativeTools then "" else gnugrep; + # stdenv.cc.cc should not be null and we have nothing better for now. + # if the native impure bootstrap is gotten rid of this can become `inherit cc;` again. + cc = if nativeTools then "" else cc; wrapperName = "CC_WRAPPER"; - inherit suffixSalt coreutils_bin bintools cc; + inherit suffixSalt coreutils_bin bintools; inherit libc_bin libc_dev libc_lib; inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable; }; From 7090651071c9fb91da728183374d515f0894e37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 18 Feb 2023 19:42:55 +0100 Subject: [PATCH 3/3] {bintools,cc}-wrapper: don't fallback to version = null mkDerivation cannot handle that --- pkgs/build-support/bintools-wrapper/default.nix | 2 +- pkgs/build-support/cc-wrapper/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 6e33f6189a4a..86b7e8d7af9a 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -100,7 +100,7 @@ in stdenv.mkDerivation { pname = targetPrefix + (if name != "" then name else "${bintoolsName}-wrapper"); - version = if bintools == null then null else bintoolsVersion; + version = if bintools == null then "" else bintoolsVersion; preferLocalBuild = true; diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index c614fe0d287a..388e006a88f9 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -126,7 +126,7 @@ assert nativePrefix == bintools.nativePrefix; stdenv.mkDerivation { pname = targetPrefix + (if name != "" then name else "${ccName}-wrapper"); - version = if cc == null then null else ccVersion; + version = if cc == null then "" else ccVersion; preferLocalBuild = true;