2020-11-06 00:33:48 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-11-06 00:33:48 +00:00
|
|
|
, libelf
|
|
|
|
, libcap
|
|
|
|
, libseccomp
|
|
|
|
, rpcsvc-proto
|
|
|
|
, libtirpc
|
2021-01-15 22:18:51 +00:00
|
|
|
, makeWrapper
|
2020-11-06 00:33:48 +00:00
|
|
|
}:
|
|
|
|
let
|
2021-01-09 10:05:03 +00:00
|
|
|
modp-ver = "450.57";
|
2020-04-24 23:36:52 +00:00
|
|
|
nvidia-modprobe = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-modprobe";
|
|
|
|
rev = modp-ver;
|
2021-01-09 10:05:03 +00:00
|
|
|
sha256 = "0r4f6lpbbqqs9932xd2mr7bxn6a3xdalcwq332fc1amrrkgzfyv7";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libnvidia-container";
|
2021-01-09 10:05:03 +00:00
|
|
|
version = "1.3.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
2021-01-15 22:18:51 +00:00
|
|
|
repo = pname;
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
2021-01-09 10:05:03 +00:00
|
|
|
sha256 = "0j6b8z9x9hrrs4xp11zyjjd7kyl7fzcicpiis8k1qb1q2afnqsrq";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
patches = [
|
|
|
|
# locations of nvidia-driver libraries are not resolved via ldconfig which
|
|
|
|
# doesn't get used on NixOS. Additional support binaries like nvidia-smi
|
|
|
|
# are not resolved via the environment PATH but via the derivation output
|
|
|
|
# path.
|
|
|
|
./libnvc-ldconfig-and-path-fixes.patch
|
|
|
|
|
|
|
|
# the libnvidia-container Makefile wants to build and install static
|
|
|
|
# libtirpc libraries; this patch prevents that from happening
|
|
|
|
./avoid-static-libtirpc-build.patch
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"WITH_LIBELF=yes"
|
|
|
|
"prefix=$(out)"
|
2020-11-06 00:33:48 +00:00
|
|
|
# we can't use the WITH_TIRPC=yes flag that exists in the Makefile for the
|
|
|
|
# same reason we patch out the static library use of libtirpc so we set the
|
|
|
|
# define in CFLAGS
|
|
|
|
"CFLAGS=-DWITH_TIRPC"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-11-06 00:33:48 +00:00
|
|
|
sed -i \
|
|
|
|
-e 's/^REVISION :=.*/REVISION = ${src.rev}/' \
|
|
|
|
-e 's/^COMPILER :=.*/COMPILER = $(CC)/' \
|
|
|
|
mk/common.mk
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
mkdir -p deps/src/nvidia-modprobe-${modp-ver}
|
|
|
|
cp -r ${nvidia-modprobe}/* deps/src/nvidia-modprobe-${modp-ver}
|
|
|
|
chmod -R u+w deps/src
|
2021-01-09 10:05:03 +00:00
|
|
|
pushd deps/src
|
|
|
|
patch -p0 < ${./modprobe.patch}
|
|
|
|
touch nvidia-modprobe-${modp-ver}/.download_stamp
|
|
|
|
popd
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
postInstall = ''
|
|
|
|
wrapProgram $out/bin/nvidia-container-cli \
|
|
|
|
--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:/run/opengl-driver-32/lib
|
|
|
|
'';
|
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
NIX_CFLAGS_COMPILE = [ "-I${libtirpc.dev}/include/tirpc" ];
|
|
|
|
NIX_LDFLAGS = [ "-L${libtirpc.dev}/lib" "-ltirpc" ];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config rpcsvc-proto makeWrapper ];
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
buildInputs = [ libelf libcap libseccomp libtirpc ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/NVIDIA/libnvidia-container";
|
|
|
|
description = "NVIDIA container runtime library";
|
2021-01-15 22:18:51 +00:00
|
|
|
license = licenses.asl20;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
2021-01-15 22:18:51 +00:00
|
|
|
maintainers = with maintainers; [ cpcloud ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|