···
# 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.
+
# 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" =
+
libIndex = lists.findFirstIndex (x: x == "lib") null finalAttrs.outputs;
+
staticIndex = lists.findFirstIndex (x: x == "static") null finalAttrs.outputs;
+
libIndex != null && staticIndex != null && libIndex > staticIndex;
# badPlatformsConditions :: AttrSet Bool
# Sets `meta.badPlatforms = meta.platforms` if any of the conditions are true.
···
# src :: Optional Derivation
+
# If redistArch doesn't exist in redistribRelease, return null.
+
src = trivial.mapNullable (
+
{ relative_path, sha256, ... }:
+
url = "https://developer.download.nvidia.com/compute/${redistName}/redist/${relative_path}";
+
) (redistribRelease.${redistArch} or null);
+
# 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/
+
# 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
+
-e "s|^cudaroot\s*=.*\$|cudaroot=''${!outputDev}|" \
+
-e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib|" \
+
-e "s|^includedir\s*=.*/include\$|includedir=''${!outputDev}/include|" \
+
# 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
env.majorMinorVersion = cudaMajorMinorVersion;
···
# 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
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
···
echo "Executing postInstallCheck"
+
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
echo "Detected references to /usr" >&2