diff --git a/pkgs/development/cuda-modules/cuda/overrides.nix b/pkgs/development/cuda-modules/cuda/overrides.nix index e40d58736e8b..d6068456e4dc 100644 --- a/pkgs/development/cuda-modules/cuda/overrides.nix +++ b/pkgs/development/cuda-modules/cuda/overrides.nix @@ -85,7 +85,20 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) { ); cuda_nvcc = prev.cuda_nvcc.overrideAttrs ( - oldAttrs: { + oldAttrs: + let + # This replicates the logic in backend-stdenv.nix, except the stdenv uses + # buildPackages and we use pkgsHostTarget. + ccForLibs-wrapper = final.pkgs.stdenv.cc; + gccMajorVersion = final.nvccCompatibilities.${cudaVersion}.gccMaxMajorVersion; + cc = final.pkgs.wrapCCWith { + cc = final.pkgs."gcc${gccMajorVersion}".cc; + useCcForLibs = true; + gccForLibs = ccForLibs-wrapper.cc; + }; + cxxStdlibDir = ccForLibs-wrapper.cxxStdlib.solib; + in + { outputs = oldAttrs.outputs ++ lists.optionals (!(builtins.elem "lib" oldAttrs.outputs)) [ "lib" ]; @@ -119,8 +132,8 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) { cat << EOF >> bin/nvcc.profile # Fix a compatible backend compiler - PATH += ${lib.getBin final.backendStdenv.cc}/bin: - LIBRARIES += "-L${lib.getLib final.backendStdenv.nixpkgsCompatibleLibstdcxx}/lib" + PATH += ${lib.getBin cc}/bin: + LIBRARIES += "-L${cxxStdlibDir}/lib" # Expose the split-out nvvm LIBRARIES =+ -L''${!outputBin}/nvvm/lib