2022-04-15 01:41:22 +00:00
|
|
|
{ lib
|
2023-04-12 12:48:02 +00:00
|
|
|
, stdenv
|
2023-03-08 16:32:21 +00:00
|
|
|
, backendStdenv
|
2022-04-15 01:41:22 +00:00
|
|
|
, fetchurl
|
|
|
|
, autoPatchelfHook
|
|
|
|
, autoAddOpenGLRunpathHook
|
2023-08-04 22:07:22 +00:00
|
|
|
, markForCudatoolkitRootHook
|
2022-04-15 01:41:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
pname:
|
|
|
|
attrs:
|
|
|
|
|
|
|
|
let
|
|
|
|
arch = "linux-x86_64";
|
2023-03-08 16:32:21 +00:00
|
|
|
in
|
|
|
|
backendStdenv.mkDerivation {
|
2022-04-15 01:41:22 +00:00
|
|
|
inherit pname;
|
|
|
|
inherit (attrs) version;
|
|
|
|
|
|
|
|
src = assert (lib.hasAttr arch attrs); fetchurl {
|
|
|
|
url = "https://developer.download.nvidia.com/compute/cuda/redist/${attrs.${arch}.relative_path}";
|
|
|
|
inherit (attrs.${arch}) sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
autoPatchelfHook
|
|
|
|
# This hook will make sure libcuda can be found
|
|
|
|
# in typically /lib/opengl-driver by adding that
|
|
|
|
# directory to the rpath of all ELF binaries.
|
|
|
|
# Check e.g. with `patchelf --print-rpath path/to/my/binary
|
|
|
|
autoAddOpenGLRunpathHook
|
2023-08-04 22:07:22 +00:00
|
|
|
markForCudatoolkitRootHook
|
2022-04-15 01:41:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2023-04-12 12:48:02 +00:00
|
|
|
# autoPatchelfHook will search for a libstdc++ and we're giving it
|
|
|
|
# one that is compatible with the rest of nixpkgs, even when
|
|
|
|
# nvcc forces us to use an older gcc
|
2023-03-08 16:32:21 +00:00
|
|
|
# NB: We don't actually know if this is the right thing to do
|
2023-04-12 12:48:02 +00:00
|
|
|
stdenv.cc.cc.lib
|
2022-04-15 01:41:22 +00:00
|
|
|
];
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
# Picked up by autoPatchelf
|
|
|
|
# Needed e.g. for libnvrtc to locate (dlopen) libnvrtc-builtins
|
|
|
|
appendRunpaths = [
|
|
|
|
"$ORIGIN"
|
|
|
|
];
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
# TODO: choose whether to install static/dynamic libs
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
rm LICENSE
|
|
|
|
mkdir -p $out
|
|
|
|
mv * $out
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2023-03-08 16:32:21 +00:00
|
|
|
passthru.stdenv = backendStdenv;
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
meta = {
|
|
|
|
description = attrs.name;
|
|
|
|
license = lib.licenses.unfree;
|
2023-05-24 13:37:59 +00:00
|
|
|
maintainers = lib.teams.cuda.members;
|
2022-04-15 01:41:22 +00:00
|
|
|
platforms = lib.optionals (lib.hasAttr arch attrs) [ "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|