summaryrefslogtreecommitdiffstats
path: root/pkgs/development/cuda-modules/generic-builders/manifest.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/cuda-modules/generic-builders/manifest.nix')
-rw-r--r--pkgs/development/cuda-modules/generic-builders/manifest.nix95
1 files changed, 53 insertions, 42 deletions
diff --git a/pkgs/development/cuda-modules/generic-builders/manifest.nix b/pkgs/development/cuda-modules/generic-builders/manifest.nix
index 73c34b0c86ee..006abb456cdc 100644
--- a/pkgs/development/cuda-modules/generic-builders/manifest.nix
+++ b/pkgs/development/cuda-modules/generic-builders/manifest.nix
@@ -10,7 +10,6 @@
markForCudatoolkitRootHook,
flags,
stdenv,
- hostPlatform,
# Builder-specific arguments
# Short package name (e.g., "cuda_cccl")
# pname : String
@@ -40,6 +39,8 @@ let
sourceTypes
;
+ inherit (stdenv) hostPlatform;
+
# Get the redist architectures for which package provides distributables.
# These are used by meta.platforms.
supportedRedistArchs = builtins.attrNames featureRelease;
@@ -48,7 +49,7 @@ let
# It is `"unsupported"` if the redistributable is not supported on the target platform.
redistArch = flags.getRedistArch hostPlatform.system;
- sourceMatchesHost = flags.getNixSystem redistArch == stdenv.hostPlatform.system;
+ sourceMatchesHost = flags.getNixSystem redistArch == hostPlatform.system;
in
backendStdenv.mkDerivation (finalAttrs: {
# NOTE: Even though there's no actual buildPhase going on here, the derivations of the
@@ -127,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.
@@ -137,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;
@@ -233,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
@@ -264,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