diff --git a/pkgs/development/cuda-modules/generic-builders/manifest.nix b/pkgs/development/cuda-modules/generic-builders/manifest.nix index e5831ef99dd0..ce45ada68fc2 100644 --- a/pkgs/development/cuda-modules/generic-builders/manifest.nix +++ b/pkgs/development/cuda-modules/generic-builders/manifest.nix @@ -128,7 +128,18 @@ backendStdenv.mkDerivation (finalAttrs: { # brokenConditions :: AttrSet Bool # Sets `meta.broken = true` if any of the conditions are true. # Example: Broken on a specific version of CUDA or when a dependency has a specific version. - brokenConditions = { }; + brokenConditions = { + # Unclear how this is handled by Nix internals. + "Duplicate entries in outputs" = finalAttrs.outputs != lists.unique finalAttrs.outputs; + # Typically this results in the static output being empty, as all libraries are moved + # back to the lib output. + "lib output follows static output" = + let + libIndex = lists.findFirstIndex (x: x == "lib") null finalAttrs.outputs; + staticIndex = lists.findFirstIndex (x: x == "static") null finalAttrs.outputs; + in + libIndex != null && staticIndex != null && libIndex > staticIndex; + }; # badPlatformsConditions :: AttrSet Bool # Sets `meta.badPlatforms = meta.platforms` if any of the conditions are true. @@ -138,44 +149,43 @@ backendStdenv.mkDerivation (finalAttrs: { }; # src :: Optional Derivation - src = trivial.pipe redistArch [ - # If redistArch doesn't exist in redistribRelease, return null. - (redistArch: redistribRelease.${redistArch} or null) - # If the release is non-null, fetch the source; otherwise, return null. - (trivial.mapNullable ( - { relative_path, sha256, ... }: - fetchurl { - url = "https://developer.download.nvidia.com/compute/${redistName}/redist/${relative_path}"; - inherit sha256; - } - )) - ]; - - # Handle the pkg-config files: - # 1. No FHS - # 2. Location expected by the pkg-config wrapper - # 3. Generate unversioned names too - postPatch = '' - for path in pkg-config pkgconfig ; do - [[ -d "$path" ]] || continue - mkdir -p share/pkgconfig - mv "$path"/* share/pkgconfig/ - rmdir "$path" - done - - for pc in share/pkgconfig/*.pc ; do - sed -i \ - -e "s|^cudaroot\s*=.*\$|cudaroot=''${!outputDev}|" \ - -e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib|" \ - -e "s|^includedir\s*=.*/include\$|includedir=''${!outputDev}/include|" \ - "$pc" - done + # If redistArch doesn't exist in redistribRelease, return null. + src = trivial.mapNullable ( + { relative_path, sha256, ... }: + fetchurl { + url = "https://developer.download.nvidia.com/compute/${redistName}/redist/${relative_path}"; + inherit sha256; + } + ) (redistribRelease.${redistArch} or null); + postPatch = + # Pkg-config's setup hook expects configuration files in $out/share/pkgconfig + '' + for path in pkg-config pkgconfig; do + [[ -d "$path" ]] || continue + mkdir -p share/pkgconfig + mv "$path"/* share/pkgconfig/ + rmdir "$path" + done + '' + # Rewrite FHS paths with store paths + # NOTE: output* fall back to out if the corresponding output isn't defined. + + '' + for pc in share/pkgconfig/*.pc; do + sed -i \ + -e "s|^cudaroot\s*=.*\$|cudaroot=''${!outputDev}|" \ + -e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib|" \ + -e "s|^includedir\s*=.*/include\$|includedir=''${!outputDev}/include|" \ + "$pc" + done + '' + # Generate unversioned names. # E.g. cuda-11.8.pc -> cuda.pc - for pc in share/pkgconfig/*-"$majorMinorVersion.pc" ; do - ln -s "$(basename "$pc")" "''${pc%-$majorMinorVersion.pc}".pc - done - ''; + + '' + for pc in share/pkgconfig/*-"$majorMinorVersion.pc"; do + ln -s "$(basename "$pc")" "''${pc%-$majorMinorVersion.pc}".pc + done + ''; env.majorMinorVersion = cudaMajorMinorVersion; @@ -234,7 +244,7 @@ backendStdenv.mkDerivation (finalAttrs: { # Handle the existence of libPath, which requires us to re-arrange the lib directory + strings.optionalString (libPath != null) '' full_lib_path="lib/${libPath}" - if [[ ! -d "$full_lib_path" ]] ; then + if [[ ! -d "$full_lib_path" ]]; then echo "${finalAttrs.pname}: '$full_lib_path' does not exist, only found:" >&2 find lib/ -mindepth 1 -maxdepth 1 >&2 echo "This release might not support your CUDA version" >&2 @@ -265,9 +275,9 @@ backendStdenv.mkDerivation (finalAttrs: { postInstallCheck = '' echo "Executing postInstallCheck" - if [[ -z "''${allowFHSReferences-}" ]] ; then + if [[ -z "''${allowFHSReferences-}" ]]; then mapfile -t outputPaths < <(for o in $(getAllOutputNames); do echo "''${!o}"; done) - if grep --max-count=5 --recursive --exclude=LICENSE /usr/ "''${outputPaths[@]}" ; then + if grep --max-count=5 --recursive --exclude=LICENSE /usr/ "''${outputPaths[@]}"; then echo "Detected references to /usr" >&2 exit 1 fi