cudnn_cudatoolkit: accept `hash` attribute for SRI hashes

This commit is contained in:
Daniël de Kok 2021-04-18 10:53:22 +02:00
parent 8bd4d8ee66
commit 7475b12169
2 changed files with 10 additions and 5 deletions

View File

@ -58,7 +58,7 @@ in rec {
# 8.1.0 is compatible with CUDA 11.0, 11.1, and 11.2:
# https://docs.nvidia.com/deeplearning/cudnn/support-matrix/index.html#cudnn-cuda-hardware-versions
srcName = "cudnn-11.2-linux-x64-v8.1.1.33.tgz";
sha256 = "sha256-mKh4TpKGLyABjSDCgbMNSgzZUfk2lPZDPM9K6cUCumo=";
hash = "sha256-mKh4TpKGLyABjSDCgbMNSgzZUfk2lPZDPM9K6cUCumo=";
};
cudnn_cudatoolkit_11_1 = cudnn_cudatoolkit_11_0.override {

View File

@ -1,8 +1,11 @@
{ version
, srcName
, sha256
, hash ? null
, sha256 ? null
}:
assert (hash != null) || (sha256 != null);
{ stdenv
, lib
, cudatoolkit
@ -22,11 +25,13 @@ stdenv.mkDerivation {
name = "cudatoolkit-${cudatoolkit.majorVersion}-cudnn-${version}";
inherit version;
src = fetchurl {
src = let
hash_ = if hash != null then { inherit hash; } else { inherit sha256; };
in fetchurl ({
# URL from NVIDIA docker containers: https://gitlab.com/nvidia/cuda/blob/centos7/7.0/runtime/cudnn4/Dockerfile
url = "https://developer.download.nvidia.com/compute/redist/cudnn/v${version}/${srcName}";
inherit sha256;
};
} // hash_);
nativeBuildInputs = [ addOpenGLRunpath ];