3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/virtualization/nvidia-docker/default.nix

88 lines
2.4 KiB
Nix
Raw Normal View History

2021-01-06 14:10:01 +00:00
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, callPackage
, makeWrapper
, buildGoModule
, buildGoPackage
, git
, glibc
}:
with lib; let
libnvidia-container = callPackage ./libnvc.nix { };
2021-01-06 14:10:01 +00: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}
'';
};
2021-01-06 14:10:01 +00:00
nvidia-container-toolkit = buildGoModule rec {
pname = "nvidia-container-toolkit";
version = "1.3.0";
src = fetchFromGitHub {
2021-01-06 14:10:01 +00:00
owner = "NVIDIA";
repo = "nvidia-container-toolkit";
rev = "v${version}";
2021-01-06 14:10:01 +00:00
sha256 = "04284bhgx4j55vg9ifvbji2bvmfjfy3h1lq7q356ffgw3yr9n0hn";
};
2021-01-06 14:10:01 +00:00
vendorSha256 = "17zpiyvf22skfcisflsp6pn56y6a793jcx89kw976fq2x5br1bz7";
buildFlagsArray = [ "-ldflags=" "-s -w" ];
postInstall = ''
mv $out/bin/{pkg,${pname}}
cp $out/bin/{${pname},nvidia-container-runtime-hook}
'';
};
2021-01-06 14:10:01 +00:00
in
stdenv.mkDerivation rec {
pname = "nvidia-docker";
2021-01-06 14:10:01 +00:00
version = "2.5.0";
src = fetchFromGitHub {
owner = "NVIDIA";
repo = "nvidia-docker";
rev = "v${version}";
2021-01-06 14:10:01 +00:00
sha256 = "1n1k7fnimky67s12p2ycaq9mgk245fchq62vgd7bl3bzfcbg0z4h";
};
nativeBuildInputs = [ makeWrapper ];
buildPhase = ''
mkdir bin
cp nvidia-docker bin
cp ${libnvidia-container}/bin/nvidia-container-cli bin
2021-01-06 14:10:01 +00:00
cp ${nvidia-container-toolkit}/bin/nvidia-container-{toolkit,runtime-hook} bin
cp ${nvidia-container-runtime}/bin/nvidia-container-runtime bin
'';
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
substituteInPlace $out/etc/config.toml --subst-var-by glibcbin ${lib.getBin glibc}
'';
meta = {
homepage = "https://github.com/NVIDIA/nvidia-docker";
description = "NVIDIA container runtime for Docker";
license = licenses.bsd3;
platforms = platforms.linux;
2021-01-06 14:10:01 +00:00
maintainers = with lib.maintainers; [ cpcloud ];
};
}