From 596a57d585cedfe6656b5f409bac04cdb0ad9cbd Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 25 Oct 2023 23:57:23 -0700 Subject: [PATCH 01/12] targetPackages_bintools: give it a top-level entry In order to avoid setting off the unspliced-dependency check, we need to make sure that the targetPackages.stdenv.cc.bintools used by gcc gets spliced. In order for it to be spliced, it needs a top-level entry in all-packages.nix. Therefore, this commit adds one. This also causes us to stop abusing targetPackages to access the linker, which is a good thing. --- .../compilers/gcc/common/configure-flags.nix | 6 +++--- .../development/compilers/gcc/common/dependencies.nix | 6 +++--- pkgs/development/compilers/gcc/default.nix | 5 +++-- pkgs/top-level/all-packages.nix | 11 +++++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index cbe38f1127f38..a066b9eeeb0b0 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -1,5 +1,5 @@ { lib, stdenv -, targetPackages +, targetPackages_bintools , withoutTargetLibc, libcCross , threadsCross @@ -56,8 +56,8 @@ let crossConfigureFlags = # Ensure that -print-prog-name is able to find the correct programs. [ - "--with-as=${if targetPackages.stdenv.cc.bintools.isLLVM then binutils else targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" - "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-as=${if targetPackages_bintools.isLLVM then binutils else targetPackages_bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages_bintools}/bin/${targetPlatform.config}-ld" ] ++ (if withoutTargetLibc then [ "--disable-libssp" diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index a38cdcb9e20f5..99a50305fe4aa 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -2,7 +2,6 @@ , stdenv , version , buildPackages -, targetPackages , texinfo , which , gettext @@ -12,6 +11,7 @@ , gmp , mpfr , libmpc +, targetPackages_bintools , libucontext ? null , libxcrypt ? null , cloog ? null @@ -62,7 +62,7 @@ in depsBuildTarget = ( if hostPlatform == buildPlatform then [ - targetPackages.stdenv.cc.bintools # newly-built gcc will be used + targetPackages_bintools # newly-built gcc will be used ] else assert targetPlatform == hostPlatform; [ # build != host == target stdenv.cc @@ -77,7 +77,7 @@ in ] ++ optionals (lib.versionAtLeast version "10") [ libxcrypt ] ++ [ - targetPackages.stdenv.cc.bintools # For linking code at run-time + targetPackages_bintools # For linking code at run-time ] ++ optionals (lib.versionOlder version "5" && cloog != null) [ cloog ] ++ optionals (isl != null) [ isl ] diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 01f1725130803..a6c8a5fec5efe 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +{ lib, stdenv, fetchurl, fetchpatch, noSysDirs , langC ? true, langCC ? true, langFortran ? false , langAda ? false , langObjC ? stdenv.targetPlatform.isDarwin @@ -14,6 +14,7 @@ , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) , gmp, mpfr, libmpc, gettext, which, patchelf, binutils +, targetPackages_bintools , isl ? null # optional, for the Graphite optimization framework. , zlib ? null , libucontext ? null @@ -173,7 +174,7 @@ let inherit version; reproducibleBuild staticCompiler stdenv - targetPackages + targetPackages_bintools texinfo threadsCross which diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3712806cf012a..c69024a7fec3d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15948,6 +15948,10 @@ with pkgs; then overrideCC stdenv buildPackages.llvmPackages.clangNoLibc else gccCrossLibcStdenv; + # This needs to have a top-level entry here in all-packages.nix in + # order to be spliced. + targetPackages_bintools = targetPackages.stdenv.cc.bintools; + # The GCC used to build libc for the target platform. Normal gccs will be # built with, and use, that cross-compiled libc. gccWithoutTargetLibc = assert stdenv.targetPlatform != stdenv.hostPlatform; let @@ -15966,7 +15970,7 @@ with pkgs; withoutTargetLibc = true; langCC = false; libcCross = libcCross1; - targetPackages.stdenv.cc.bintools = binutilsNoLibc; + targetPackages_bintools = __splicedPackages.binutilsNoLibc; enableShared = stdenv.targetPlatform.hasSharedLibraries @@ -18630,7 +18634,10 @@ with pkgs; enableGold = false; }; }); - binutilsNoLibc = wrapBintoolsWith { + binutilsNoLibc = + # this `if..then null else` is an ugly hack to prevent infinite recursion + if stdenv.hostPlatform == stdenv.targetPlatform then null else + wrapBintoolsWith { bintools = binutils-unwrapped; libc = preLibcCrossHeaders; }; From 61f0912c59df0e06d8f1242368873a7dde3b43bc Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 00:01:13 -0700 Subject: [PATCH 02/12] stdenv: lib.warn if drv.__splice is missing when expected This commit adds a `lib.warn` check to stdenv.mkDerivation, causing it to emit a warning if a dependency which ought to be spliced in fact is not. --- pkgs/stdenv/generic/make-derivation.nix | 43 ++++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 63d02c8f08570..e9199f7ff2732 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -283,32 +283,51 @@ else let references = nativeBuildInputs ++ buildInputs ++ propagatedNativeBuildInputs ++ propagatedBuildInputs; + getSpliced = type: drv: + drv.__spliced or + ( assert + (drv?stdenv && + drv.stdenv.buildPlatform != drv.stdenv.targetPlatform && + + # I can't test on Darwin, so let's just ignore it for now. + !drv.stdenv.buildPlatform.isDarwin && + !drv.stdenv.hostPlatform.isDarwin && + !drv.stdenv.targetPlatform.isDarwin + ) + -> lib.warn + ''derivation ${attrs.pname or "!!no pname!!"}: + unspliced ${type} dependency ${toString drv} + build=${drv.stdenv.buildPlatform.config} + target=${drv.stdenv.targetPlatform.config} + '' true; + {}); + dependencies = map (map chooseDevOutputs) [ [ - (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild)) - (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs')) - (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget)) + (map (drv: (getSpliced "build-build" drv).buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild)) + (map (drv: (getSpliced "build-host" drv).buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs')) + (map (drv: (getSpliced "build-target" drv).buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget)) ] [ - (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost)) - (map (drv: drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) + (map (drv: (getSpliced "host-host" drv).hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost)) + (map (drv: (getSpliced "host-target" drv).hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) ] [ - (map (drv: drv.__spliced.targetTarget or drv) (checkDependencyList "depsTargetTarget" depsTargetTarget)) + (map (drv: (getSpliced "target-target" drv).targetTarget or drv) (checkDependencyList "depsTargetTarget" depsTargetTarget)) ] ]; propagatedDependencies = map (map chooseDevOutputs) [ [ - (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuildPropagated" depsBuildBuildPropagated)) - (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "propagatedNativeBuildInputs" propagatedNativeBuildInputs)) - (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTargetPropagated" depsBuildTargetPropagated)) + (map (drv: (getSpliced "build-build propagated" drv).buildBuild or drv) (checkDependencyList "depsBuildBuildPropagated" depsBuildBuildPropagated)) + (map (drv: (getSpliced "build-host propagated" drv).buildHost or drv) (checkDependencyList "propagatedNativeBuildInputs" propagatedNativeBuildInputs)) + (map (drv: (getSpliced "build-target propagated" drv).buildTarget or drv) (checkDependencyList "depsBuildTargetPropagated" depsBuildTargetPropagated)) ] [ - (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) - (map (drv: drv.__spliced.hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) + (map (drv: (getSpliced "host-host propagated" drv).hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) + (map (drv: (getSpliced "host-target propagated" drv).hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) ] [ - (map (drv: drv.__spliced.targetTarget or drv) (checkDependencyList "depsTargetTargetPropagated" depsTargetTargetPropagated)) + (map (drv: (getSpliced "target-target propagated" drv).targetTarget or drv) (checkDependencyList "depsTargetTargetPropagated" depsTargetTargetPropagated)) ] ]; From 23bbc793521ce71711edc9c93397e86148cd2062 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 22:08:32 -0700 Subject: [PATCH 03/12] stdenv: allow unspliced hostTarget dependencies (for now) --- pkgs/stdenv/generic/make-derivation.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index e9199f7ff2732..144a5ef278e68 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -310,7 +310,8 @@ else let ] [ (map (drv: (getSpliced "host-host" drv).hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost)) - (map (drv: (getSpliced "host-target" drv).hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) + (map (drv: drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) + #(map (drv: (getSpliced "host-target" drv).hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) ] [ (map (drv: (getSpliced "target-target" drv).targetTarget or drv) (checkDependencyList "depsTargetTarget" depsTargetTarget)) @@ -324,7 +325,8 @@ else let ] [ (map (drv: (getSpliced "host-host propagated" drv).hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) - (map (drv: (getSpliced "host-target propagated" drv).hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) + (map (drv: drv.__spliced.hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) + #(map (drv: (getSpliced "host-target propagated" drv).hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) ] [ (map (drv: (getSpliced "target-target propagated" drv).targetTarget or drv) (checkDependencyList "depsTargetTargetPropagated" depsTargetTargetPropagated)) From 6cae19e98f1732706f3c2cffda2b33912ea2c26e Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 22:28:00 -0700 Subject: [PATCH 04/12] stdenv: add list-of-shame Co-authored-by: Artturi --- pkgs/stdenv/generic/make-derivation.nix | 73 ++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 144a5ef278e68..bb3c09b5805ae 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -1,3 +1,67 @@ +let + + # + # This is a list of pnames of packages that have failed to splice. + # Every one of these is an unfixed bug. Please fix them instead + # of taking shameful behavior, you scoundrel! + # + list-of-shame = + builtins.listToAttrs + (builtins.map + (name: { inherit name; value = true; }) + [ + # shame on you, python + "wrap-python-hook" + "python-imports-check-hook.sh" + "python-namespaces-hook.sh" + "wrap-python-hook" + "pytest-check-hook" + "python-remove-tests-dir-hook" + "python-catch-conflicts-hook" + "python-remove-bin-bytecode-hook" + "python-output-dist-hook" + "python-remove-tests-dir-hook" + "wrap-python-hook" + "setuptools-setup-hook" + "pypa-build-hook.sh" + "pypa-install-hook" + "python3-3.11.5-env" + "setuptools-check-hook" + "unittest-check-hook" + + # shame on you, llvm! + "llvm" + "compiler-rt" + "libcxx" + "libcxxabi" + "libunwind" + + # shame on you, embedded ARM! + "arm-none-eabi-stage-final-gcc-wrapper" + "arm-none-eabi-binutils-wrapper" + + # wasm doesn't care about shamefulness, so I won't bother... + "rustc-wasm32" + + # windows + # has overrides which discard splicing + # improvement: convert makeScope to makeScopeWithSplicing' + # may not fix it but it'll improve the set + # https://github.com/NixOS/nixpkgs/blob/53aa767c849b159cdb8c59dce4a5a44f167fc31b/pkgs/os-specific/windows/default.nix#L20 + "mcfgthreads" + "i686-w64-mingw32-stage-final-gcc-wrapper" + "x86_64-w64-mingw32-stage-final-gcc-wrapper" + + # other shameful derivations + "git-minimal" + "busybox" + "avr-stage-final-gcc-wrapper" + "boost-build" + "cmake-boot" + "perl" # only for libxcrypt; we should fix this + ]); +in + { lib, config }: stdenv: @@ -285,18 +349,21 @@ else let getSpliced = type: drv: drv.__spliced or - ( assert + (let approximate-pname = drv.pname or drv.name; in + assert (drv?stdenv && drv.stdenv.buildPlatform != drv.stdenv.targetPlatform && # I can't test on Darwin, so let's just ignore it for now. !drv.stdenv.buildPlatform.isDarwin && !drv.stdenv.hostPlatform.isDarwin && - !drv.stdenv.targetPlatform.isDarwin + !drv.stdenv.targetPlatform.isDarwin && + + !(list-of-shame ? ${approximate-pname}) ) -> lib.warn ''derivation ${attrs.pname or "!!no pname!!"}: - unspliced ${type} dependency ${toString drv} + unspliced ${type} dependency ${approximate-pname} build=${drv.stdenv.buildPlatform.config} target=${drv.stdenv.targetPlatform.config} '' true; From 849df932a12e2fd3c00d7363bd3cc8495018e3ed Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 22:01:41 -0700 Subject: [PATCH 05/12] gcc: use stdenv.cc.bintools instead of targetPackages_bintools in buildInputs --- pkgs/development/compilers/gcc/common/dependencies.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index 99a50305fe4aa..6d46ef9fcba74 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -77,7 +77,7 @@ in ] ++ optionals (lib.versionAtLeast version "10") [ libxcrypt ] ++ [ - targetPackages_bintools # For linking code at run-time + stdenv.cc.bintools # For linking code at run-time ] ++ optionals (lib.versionOlder version "5" && cloog != null) [ cloog ] ++ optionals (isl != null) [ isl ] From a42fd7a41edbb017e831628f7565d8ea11766de7 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 22:07:37 -0700 Subject: [PATCH 06/12] isl: fix splicing failure --- pkgs/development/compilers/gcc/all.nix | 3 ++- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/gcc/all.nix b/pkgs/development/compilers/gcc/all.nix index 70b4b75369a7d..618e2a6f24a9c 100644 --- a/pkgs/development/compilers/gcc/all.nix +++ b/pkgs/development/compilers/gcc/all.nix @@ -11,6 +11,7 @@ , cloog_0_18_0, cloog , lowPrio , wrapCC +, __splicedPackages }@args: let @@ -27,7 +28,7 @@ let libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then args.libcCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor majorMinorVersion else { }; isl = if stdenv.isDarwin then null - else if atLeast "9" then isl_0_20 + else if atLeast "9" then __splicedPackages.isl_0_20 else if atLeast "7" then isl_0_17 else if atLeast "6" then (if stdenv.targetPlatform.isRedox then isl_0_17 else isl_0_14) else if atLeast "4.9" then isl_0_11 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c69024a7fec3d..81c639c0613d3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15965,7 +15965,7 @@ with pkgs; reproducibleBuild = true; profiledCompiler = false; - isl = if !stdenv.isDarwin then isl_0_20 else null; + isl = if !stdenv.isDarwin then __splicedPackages.isl_0_20 else null; withoutTargetLibc = true; langCC = false; From 1b1cd5d735d28e2b0d82bbbe8a032492e5fb6b15 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 23:04:14 -0700 Subject: [PATCH 07/12] rustc-wasm32: give it a custom pname for stdenv list-of-shame --- pkgs/top-level/all-packages.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 81c639c0613d3..dfe24a7ab9b69 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16967,6 +16967,7 @@ with pkgs; }; }; }).overrideAttrs (old: { + pname = "rustc-wasm32"; configureFlags = old.configureFlags ++ ["--set=build.docs=false"]; }); From 6a5f5a9986be2762b72a7323fd72f8c5c4998415 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 24 Oct 2023 23:04:33 -0700 Subject: [PATCH 08/12] cracklib: do not use buildPackages for self-reference (fails to splice) --- pkgs/development/libraries/cracklib/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/cracklib/default.nix b/pkgs/development/libraries/cracklib/default.nix index 4c0badf3df7ce..16db40bdf9cfa 100644 --- a/pkgs/development/libraries/cracklib/default.nix +++ b/pkgs/development/libraries/cracklib/default.nix @@ -1,5 +1,6 @@ let version = "2.9.11"; in { stdenv, lib, buildPackages, fetchurl, zlib, gettext +, cracklib , lists ? [ (fetchurl { url = "https://github.com/cracklib/cracklib/releases/download/v${version}/cracklib-words-${version}.gz"; hash = "sha256-popxGjE1c517Z+nzYLM/DU7M+b1/rE0XwNXkVqkcUXo="; @@ -15,7 +16,7 @@ stdenv.mkDerivation rec { hash = "sha256-yosEmjwtOyIloejRXWE3mOvHSOOVA4jtomlN5Qe6YCA="; }; - nativeBuildInputs = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.cracklib; + nativeBuildInputs = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) cracklib; buildInputs = [ zlib gettext ]; postPatch = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' From e178e102cee7ee5c7e02f4ae6032d8243fbe6979 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 26 Oct 2023 01:21:39 -0700 Subject: [PATCH 09/12] stdenv: alphabetize list-of-shame --- pkgs/stdenv/generic/make-derivation.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index bb3c09b5805ae..0426e4736269a 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -11,23 +11,23 @@ let (name: { inherit name; value = true; }) [ # shame on you, python - "wrap-python-hook" - "python-imports-check-hook.sh" - "python-namespaces-hook.sh" - "wrap-python-hook" + "pypa-build-hook.sh" + "pypa-install-hook" "pytest-check-hook" - "python-remove-tests-dir-hook" "python-catch-conflicts-hook" - "python-remove-bin-bytecode-hook" + "python-imports-check-hook.sh" + "python-namespaces-hook.sh" "python-output-dist-hook" + "python-remove-bin-bytecode-hook" + "python-remove-tests-dir-hook" "python-remove-tests-dir-hook" - "wrap-python-hook" - "setuptools-setup-hook" - "pypa-build-hook.sh" - "pypa-install-hook" "python3-3.11.5-env" "setuptools-check-hook" + "setuptools-setup-hook" "unittest-check-hook" + "wrap-python-hook" + "wrap-python-hook" + "wrap-python-hook" # shame on you, llvm! "llvm" From 8891c0a74a4cc272dbc80afbb14d8e323cfd6310 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 26 Oct 2023 01:22:02 -0700 Subject: [PATCH 10/12] stdenv: improve diagnostics for unspliced-dependency check --- pkgs/stdenv/generic/make-derivation.nix | 53 ++++++++++++++++++++----- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 0426e4736269a..bbc9ed5c8afd7 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -347,25 +347,58 @@ else let references = nativeBuildInputs ++ buildInputs ++ propagatedNativeBuildInputs ++ propagatedBuildInputs; - getSpliced = type: drv: - drv.__spliced or - (let approximate-pname = drv.pname or drv.name; in + getSpliced = type: dep: + dep.__spliced or + (let approximate-pname = dep.pname or dep.name; in assert - (drv?stdenv && - drv.stdenv.buildPlatform != drv.stdenv.targetPlatform && + (dep?stdenv && + dep.stdenv.buildPlatform != dep.stdenv.targetPlatform && # I can't test on Darwin, so let's just ignore it for now. - !drv.stdenv.buildPlatform.isDarwin && - !drv.stdenv.hostPlatform.isDarwin && - !drv.stdenv.targetPlatform.isDarwin && + !dep.stdenv.buildPlatform.isDarwin && + !dep.stdenv.hostPlatform.isDarwin && + !dep.stdenv.targetPlatform.isDarwin && !(list-of-shame ? ${approximate-pname}) ) + + # Hi there! If you're reading this, it's probably + # because the line below caused your PR to fail CI. + # Don't panic! Most likely, what happened is that you + # used one of the following as a dependency: + # + # - `buildPackages.something` + # - `targetPackages.something` + # - `pkgs{Build,Host,Target}{Build,Host,Target}.something` + # + # You can't use those as dependencies (i.e. in a + # `buildInputs`, `nativeBuildInputs`, or + # `deps{Build,Host,Target}{Build,Host,Target}` + # attribute). The reason is a bit obscure, but the fix + # is easy: just use `something` instead! The explicit + # packagesets (the three bullet points above) are mainly + # for when you need to reference a package with string + # interpolation (e.g. "cat blah | ${buildPackages.jq}"). + # For dependencies, you control which packageset is used + # by *which attribute you put the dependency in* -- if + # you put it in `depsBuildHost`, it will get pulled from + # `pkgsBuildHost`. + # + # Please take a moment to try to fix your PR. If you + # can't get it fixed, ping @amjoseph-nixpkgs who can + # help you fix it. If this is a crisis situation and + # the future of humanity depends on your PR passing CI + # pronto, you can mute the warning by adding your + # package's `pname` to the `list-of-shame` at the top of + # this file. But please don't do that. + # -> lib.warn ''derivation ${attrs.pname or "!!no pname!!"}: unspliced ${type} dependency ${approximate-pname} - build=${drv.stdenv.buildPlatform.config} - target=${drv.stdenv.targetPlatform.config} + build=${dep.stdenv.buildPlatform.config} + host=${dep.stdenv.hostPlatform.config} + target=${dep.stdenv.targetPlatform.config} + For advice on fixing this, read the comment above the lib.warn that produced this message. '' true; {}); From ec58a9ef9e089642565706bd182b12cc37e52bfa Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 26 Oct 2023 01:25:11 -0700 Subject: [PATCH 11/12] Revert "gcc: use stdenv.cc.bintools instead of targetPackages_bintools in buildInputs" This reverts commit 0899b6b8746790eec9dc49ea4f4a6c3def072e3b. --- pkgs/development/compilers/gcc/common/dependencies.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index 6d46ef9fcba74..99a50305fe4aa 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -77,7 +77,7 @@ in ] ++ optionals (lib.versionAtLeast version "10") [ libxcrypt ] ++ [ - stdenv.cc.bintools # For linking code at run-time + targetPackages_bintools # For linking code at run-time ] ++ optionals (lib.versionOlder version "5" && cloog != null) [ cloog ] ++ optionals (isl != null) [ isl ] From bf46f5e1a03a277348f83e3c5c004468203078ed Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Thu, 19 Oct 2023 14:16:59 -0400 Subject: [PATCH 12/12] setuptools-rust-hook: Use correct python for cross --- pkgs/development/interpreters/python/hooks/default.nix | 2 ++ .../interpreters/python/hooks/setuptools-rust-hook.sh | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index f7cc10274ae36..2a30d63fc98ea 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -188,7 +188,9 @@ in { name = "setuptools-rust-setup-hook"; propagatedBuildInputs = [ setuptools-rust ]; substitutions = { + pyIncludeDir = "${python}/include/${python.libPrefix}"; pyLibDir = "${python}/lib/${python.libPrefix}"; + pyBin = python.interpreter; cargoBuildTarget = stdenv.hostPlatform.rust.rustcTargetSpec; cargoLinkerVar = stdenv.hostPlatform.rust.cargoEnvVarTarget; targetLinker = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; diff --git a/pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh b/pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh index 917c19ef9b31b..c2cda07d9bd1d 100644 --- a/pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh +++ b/pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh @@ -7,7 +7,9 @@ setuptoolsRustSetup() { exit 1 fi - export PYO3_CROSS_LIB_DIR="@pyLibDir@" + export PYO3_CROSS_INCLUDE_DIR="@pyIncludeDir@"; + export PYO3_CROSS_LIB_DIR="@pyLibDir@"; + export PYO3_PYTHON="@pyBin@"; export CARGO_BUILD_TARGET=@cargoBuildTarget@ # TODO theoretically setting linker should not be required because it is # already set in pkgs/build-support/rust/hooks/default.nix but build fails