2021-01-09 10:05:03 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, callPackage
|
|
|
|
, makeWrapper
|
|
|
|
, buildGoModule
|
|
|
|
, buildGoPackage
|
|
|
|
, glibc
|
|
|
|
, docker
|
|
|
|
, linkFarm
|
|
|
|
, containerRuntimePath ? "${docker}/libexec/docker/runc"
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
with lib; let
|
|
|
|
libnvidia-container = callPackage ./libnvc.nix { };
|
2021-01-09 10:05:03 +00:00
|
|
|
isolatedContainerRuntimePath = linkFarm "isolated_container_runtime_path" [
|
|
|
|
{
|
|
|
|
name = "runc";
|
|
|
|
path = containerRuntimePath;
|
|
|
|
}
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
nvidia-container-runtime = buildGoPackage rec {
|
|
|
|
pname = "nvidia-container-runtime";
|
|
|
|
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}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
nvidia-container-toolkit = buildGoModule rec {
|
|
|
|
pname = "nvidia-container-toolkit";
|
|
|
|
version = "1.3.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-01-09 10:05:03 +00:00
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-container-toolkit";
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
2021-01-09 10:05:03 +00:00
|
|
|
sha256 = "04284bhgx4j55vg9ifvbji2bvmfjfy3h1lq7q356ffgw3yr9n0hn";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-01-09 10:05:03 +00:00
|
|
|
vendorSha256 = "17zpiyvf22skfcisflsp6pn56y6a793jcx89kw976fq2x5br1bz7";
|
|
|
|
buildFlagsArray = [ "-ldflags=" "-s -w" ];
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/{pkg,${pname}}
|
|
|
|
cp $out/bin/{${pname},nvidia-container-runtime-hook}
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "nvidia-docker";
|
2021-01-09 10:05:03 +00:00
|
|
|
version = "2.5.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-docker";
|
|
|
|
rev = "v${version}";
|
2021-01-09 10:05:03 +00:00
|
|
|
sha256 = "1n1k7fnimky67s12p2ycaq9mgk245fchq62vgd7bl3bzfcbg0z4h";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir bin
|
2021-01-09 10:05:03 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
cp nvidia-docker bin
|
2021-01-09 10:05:03 +00:00
|
|
|
substituteInPlace bin/nvidia-docker --subst-var-by VERSION ${version}
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
cp ${libnvidia-container}/bin/nvidia-container-cli bin
|
2021-01-09 10:05:03 +00:00
|
|
|
cp ${nvidia-container-toolkit}/bin/nvidia-container-{toolkit,runtime-hook} bin
|
|
|
|
cp ${nvidia-container-runtime}/bin/nvidia-container-runtime bin
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/{bin,etc}
|
|
|
|
cp -r bin $out
|
2021-01-09 10:05:03 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapProgram $out/bin/nvidia-container-cli \
|
|
|
|
--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:/run/opengl-driver-32/lib
|
2021-01-09 10:05:03 +00:00
|
|
|
|
|
|
|
# nvidia-container-runtime invokes docker-runc or runc if that isn't available on PATH
|
|
|
|
wrapProgram $out/bin/nvidia-container-runtime --prefix PATH : ${isolatedContainerRuntimePath}
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
cp ${./config.toml} $out/etc/config.toml
|
2020-08-20 17:08:02 +00:00
|
|
|
substituteInPlace $out/etc/config.toml --subst-var-by glibcbin ${lib.getBin glibc}
|
2021-01-09 10:05:03 +00:00
|
|
|
|
|
|
|
cp ${./podman-config.toml} $out/etc/podman-config.toml
|
|
|
|
substituteInPlace $out/etc/podman-config.toml --subst-var-by glibcbin ${lib.getBin glibc}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://github.com/NVIDIA/nvidia-docker";
|
|
|
|
description = "NVIDIA container runtime for Docker";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.linux;
|
2021-01-09 10:05:03 +00:00
|
|
|
maintainers = with lib.maintainers; [ cpcloud ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|