2021-01-06 15:10:01 +01:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, callPackage
|
|
|
|
, makeWrapper
|
|
|
|
, buildGoModule
|
|
|
|
, buildGoPackage
|
|
|
|
, git
|
|
|
|
, glibc
|
|
|
|
}:
|
2019-02-27 09:44:05 +01:00
|
|
|
|
|
|
|
with lib; let
|
|
|
|
libnvidia-container = callPackage ./libnvc.nix { };
|
|
|
|
|
2021-01-06 15:10:01 +01:00
|
|
|
nvidia-container-runtime = buildGoPackage rec {
|
|
|
|
pname = "nvidia-container-toolkit";
|
|
|
|
version = "3.4.0";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-container-runtime";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "095mks0r4079vawi50pk4zb5jk0g6s9idg2s1w55a0d27jkknldr";
|
|
|
|
};
|
|
|
|
goPackagePath = "github.com/nvidia-container-runtime/src";
|
|
|
|
buildFlagsArray = [ "-ldflags=" "-s -w" ];
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/{src,nvidia-container-runtime}
|
|
|
|
'';
|
2019-02-27 09:44:05 +01:00
|
|
|
};
|
|
|
|
|
2021-01-06 15:10:01 +01:00
|
|
|
nvidia-container-toolkit = buildGoModule rec {
|
|
|
|
pname = "nvidia-container-toolkit";
|
|
|
|
version = "1.3.0";
|
2019-02-27 09:44:05 +01:00
|
|
|
src = fetchFromGitHub {
|
2021-01-06 15:10:01 +01:00
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-container-toolkit";
|
2019-02-27 09:44:05 +01:00
|
|
|
rev = "v${version}";
|
2021-01-06 15:10:01 +01:00
|
|
|
sha256 = "04284bhgx4j55vg9ifvbji2bvmfjfy3h1lq7q356ffgw3yr9n0hn";
|
2019-02-27 09:44:05 +01:00
|
|
|
};
|
2021-01-06 15:10:01 +01:00
|
|
|
vendorSha256 = "17zpiyvf22skfcisflsp6pn56y6a793jcx89kw976fq2x5br1bz7";
|
|
|
|
buildFlagsArray = [ "-ldflags=" "-s -w" ];
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/{pkg,${pname}}
|
|
|
|
cp $out/bin/{${pname},nvidia-container-runtime-hook}
|
|
|
|
'';
|
|
|
|
};
|
2019-02-27 09:44:05 +01:00
|
|
|
|
2021-01-06 15:10:01 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "nvidia-docker";
|
2021-01-06 15:10:01 +01:00
|
|
|
version = "2.5.0";
|
2019-02-27 09:44:05 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-docker";
|
|
|
|
rev = "v${version}";
|
2021-01-06 15:10:01 +01:00
|
|
|
sha256 = "1n1k7fnimky67s12p2ycaq9mgk245fchq62vgd7bl3bzfcbg0z4h";
|
2019-02-27 09:44:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir bin
|
2021-01-07 21:56:08 +01:00
|
|
|
|
2019-02-27 09:44:05 +01:00
|
|
|
cp nvidia-docker bin
|
2021-01-07 21:56:08 +01:00
|
|
|
substituteInPlace bin/nvidia-docker --subst-var-by VERSION ${version}
|
|
|
|
|
2019-02-27 09:44:05 +01:00
|
|
|
cp ${libnvidia-container}/bin/nvidia-container-cli bin
|
2021-01-06 15:10:01 +01:00
|
|
|
cp ${nvidia-container-toolkit}/bin/nvidia-container-{toolkit,runtime-hook} bin
|
|
|
|
cp ${nvidia-container-runtime}/bin/nvidia-container-runtime bin
|
2019-02-27 09:44:05 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/{bin,etc}
|
|
|
|
cp -r bin $out
|
|
|
|
wrapProgram $out/bin/nvidia-container-cli \
|
|
|
|
--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:/run/opengl-driver-32/lib
|
|
|
|
cp ${./config.toml} $out/etc/config.toml
|
2020-07-30 00:36:30 +02:00
|
|
|
substituteInPlace $out/etc/config.toml --subst-var-by glibcbin ${lib.getBin glibc}
|
2019-02-27 09:44:05 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://github.com/NVIDIA/nvidia-docker";
|
2019-02-27 09:44:05 +01:00
|
|
|
description = "NVIDIA container runtime for Docker";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.linux;
|
2021-01-06 15:10:01 +01:00
|
|
|
maintainers = with lib.maintainers; [ cpcloud ];
|
2019-02-27 09:44:05 +01:00
|
|
|
};
|
|
|
|
}
|