cuda-modules/generic-builders/manifest: add to brokenConditions, simplify src, break out comments in postPatch

Changed files
+50 -40
pkgs
development
cuda-modules
generic-builders
+50 -40
pkgs/development/cuda-modules/generic-builders/manifest.nix
···
# 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.
···
};
# 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;
···
# 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
···
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