From 9230c2cc8d9b98f302fda10436b08185f5cb9eea Mon Sep 17 00:00:00 2001 From: Connor Baker Date: Mon, 8 Apr 2024 21:33:48 +0000 Subject: [PATCH] cudaPackages.markForCudatoolkitRootHook: fix bug with strictDeps The setupCudaHook always checks for the existence of `$prefix/nix-support/include-in-cudatoolkit-root`, so we need to be sure it always exists. It isn't populated when `strictDeps` is set, but it must exist. --- .../mark-for-cudatoolkit-root-hook.sh | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkgs/development/cuda-modules/setup-hooks/mark-for-cudatoolkit-root-hook.sh b/pkgs/development/cuda-modules/setup-hooks/mark-for-cudatoolkit-root-hook.sh index cea82d817a12..0abd651005c6 100644 --- a/pkgs/development/cuda-modules/setup-hooks/mark-for-cudatoolkit-root-hook.sh +++ b/pkgs/development/cuda-modules/setup-hooks/mark-for-cudatoolkit-root-hook.sh @@ -1,14 +1,25 @@ # shellcheck shell=bash -# Should we mimick cc-wrapper's "hygiene"? -[[ -z ${strictDeps-} ]] || (( "$hostOffset" < 0 )) || return 0 +(( ${hostOffset:?} == -1 && ${targetOffset:?} == 0)) || return 0 echo "Sourcing mark-for-cudatoolkit-root-hook" >&2 markForCUDAToolkit_ROOT() { - mkdir -p "${prefix}/nix-support" - [[ -f "${prefix}/nix-support/include-in-cudatoolkit-root" ]] && return 0 - echo "$pname-$output" > "${prefix}/nix-support/include-in-cudatoolkit-root" + mkdir -p "${prefix:?}/nix-support" + local markerPath="$prefix/nix-support/include-in-cudatoolkit-root" + + # Return early if the file already exists. + [[ -f "$markerPath" ]] && return 0 + + # Always create the file, even if it's empty, since setup-cuda-hook relies on its existence. + # However, only populate it if strictDeps is not set. + touch "$markerPath" + + # Return early if strictDeps is set. + [[ -n "${strictDeps-}" ]] && return 0 + + # Populate the file with the package name and output. + echo "${pname:?}-${output:?}" > "$markerPath" } fixupOutputHooks+=(markForCUDAToolkit_ROOT)