diff options
Diffstat (limited to 'pkgs/development/cuda-modules/generic-builders/manifest.nix')
-rw-r--r-- | pkgs/development/cuda-modules/generic-builders/manifest.nix | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/pkgs/development/cuda-modules/generic-builders/manifest.nix b/pkgs/development/cuda-modules/generic-builders/manifest.nix index 71c914c8c8f24..5a4c5280d7dbd 100644 --- a/pkgs/development/cuda-modules/generic-builders/manifest.nix +++ b/pkgs/development/cuda-modules/generic-builders/manifest.nix @@ -77,7 +77,7 @@ backendStdenv.mkDerivation ( false featureRelease; # Order is important here so we use a list. - additionalOutputs = builtins.filter hasOutput [ + possibleOutputs = [ "bin" "lib" "static" @@ -86,15 +86,22 @@ backendStdenv.mkDerivation ( "sample" "python" ]; + additionalOutputs = + if redistArch == "unsupported" then possibleOutputs else builtins.filter hasOutput possibleOutputs; # The out output is special -- it's the default output and we always include it. - outputs = ["out"] ++ additionalOutputs; + outputs = [ "out" ] ++ additionalOutputs; in outputs; # Traversed in the order of the outputs speficied in outputs; # entries are skipped if they don't exist in outputs. outputToPatterns = { - bin = ["bin"]; + bin = [ "bin" ]; + dev = [ + "share/pkg-config" + "**/*.pc" + "**/*.cmake" + ]; lib = [ "lib" "lib64" @@ -110,12 +117,32 @@ backendStdenv.mkDerivation ( brokenConditions = {}; src = fetchurl { - url = "https://developer.download.nvidia.com/compute/${redistName}/redist/${ - redistribRelease.${redistArch}.relative_path - }"; - inherit (redistribRelease.${redistArch}) sha256; + url = + if (builtins.hasAttr redistArch redistribRelease) then + "https://developer.download.nvidia.com/compute/${redistName}/redist/${ + redistribRelease.${redistArch}.relative_path + }" + else + "cannot-construct-an-url-for-the-${redistArch}-platform"; + sha256 = redistribRelease.${redistArch}.sha256 or lib.fakeHash; }; + postPatch = '' + if [[ -d pkg-config ]] ; then + mkdir -p share/pkg-config + mv pkg-config/* share/pkg-config/ + rmdir pkg-config + fi + + for pc in share/pkg-config/*.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 + ''; + # We do need some other phases, like configurePhase, so the multiple-output setup hook works. dontBuild = true; @@ -197,6 +224,20 @@ backendStdenv.mkDerivation ( runHook postInstall ''; + doInstallCheck = true; + allowFHSReferences = true; # TODO: Default to `false` + postInstallCheck = '' + 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 + exit 1 + fi + fi + ''; + # libcuda needs to be resolved during runtime # NOTE: Due to the use of __structuredAttrs, we can't use a list for autoPatchelfIgnoreMissingDeps, since it # will take only the first value. Instead, we produce a string with the values separated by spaces. @@ -248,9 +289,9 @@ backendStdenv.mkDerivation ( ( redistArch: let - nixSystem = builtins.tryEval (flags.getNixSystem redistArch); + nixSystem = flags.getNixSystem redistArch; in - if nixSystem.success then [nixSystem.value] else [] + lists.optionals (!(strings.hasPrefix "unsupported-" nixSystem)) [ nixSystem ] ) supportedRedistArchs; broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions); |