2020-11-03 12:17:06 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pkgconfig
|
|
|
|
, libelf
|
|
|
|
, libcap
|
|
|
|
, libseccomp
|
|
|
|
, rpcsvc-proto
|
|
|
|
, libtirpc
|
|
|
|
}:
|
|
|
|
let
|
2019-02-27 08:44:05 +00:00
|
|
|
modp-ver = "396.51";
|
|
|
|
nvidia-modprobe = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "nvidia-modprobe";
|
|
|
|
rev = modp-ver;
|
|
|
|
sha256 = "1fw2qwc84k64agw6fx2v0mjf88aggph9c6qhs4cv7l3gmflv8qbk";
|
|
|
|
};
|
2020-11-03 12:17:06 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "libnvidia-container";
|
2020-04-27 03:18:00 +01:00
|
|
|
version = "1.0.6";
|
2019-02-27 08:44:05 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = "libnvidia-container";
|
|
|
|
rev = "v${version}";
|
2020-04-27 03:18:00 +01:00
|
|
|
sha256 = "1pnpc9knwh8d1zqb28zc3spkjc00w0z10vd3jna8ksvpl35jl7w3";
|
2019-02-27 08:44:05 +00:00
|
|
|
};
|
|
|
|
|
2020-11-03 12:17:06 +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
|
|
|
|
];
|
2019-02-27 08:44:05 +00:00
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"WITH_LIBELF=yes"
|
|
|
|
"prefix=$(out)"
|
2020-11-03 12:17:06 +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"
|
2019-02-27 08:44:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-11-03 12:17:06 +00:00
|
|
|
sed -i \
|
|
|
|
-e 's/^REVISION :=.*/REVISION = ${src.rev}/' \
|
|
|
|
-e 's/^COMPILER :=.*/COMPILER = $(CC)/' \
|
|
|
|
mk/common.mk
|
2019-02-27 08:44:05 +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
|
|
|
|
touch deps/src/nvidia-modprobe-${modp-ver}/.download_stamp
|
|
|
|
'';
|
|
|
|
|
2020-11-03 12:17:06 +00:00
|
|
|
NIX_CFLAGS_COMPILE = [ "-I${libtirpc.dev}/include/tirpc" ];
|
|
|
|
NIX_LDFLAGS = [ "-L${libtirpc.dev}/lib" "-ltirpc" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ pkgconfig rpcsvc-proto ];
|
2020-04-27 03:18:00 +01:00
|
|
|
|
2020-11-03 12:17:06 +00:00
|
|
|
buildInputs = [ libelf libcap libseccomp libtirpc ];
|
2019-02-27 08:44:05 +00:00
|
|
|
|
2020-11-03 12:17:06 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/NVIDIA/libnvidia-container";
|
2019-02-27 08:44:05 +00:00
|
|
|
description = "NVIDIA container runtime library";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|