20 modprobeVersion = "550.54.14";
21 patchedModprobe = applyPatches {
22 src = nvidia-modprobe.src.override {
23 version = modprobeVersion;
24 hash = "sha256-iBRMkvOXacs/llTtvc/ZC5i/q9gc8lMuUHxMbu8A+Kg=";
27 (replaceVars ./modprobe.patch {
28 inherit modprobeVersion;
33 stdenv.mkDerivation rec {
34 pname = "libnvidia-container";
37 src = fetchFromGitHub {
39 repo = "libnvidia-container";
41 hash = "sha256-JmJKvAOEPyjVx2Frd0tAMBjnAUTMpMh1KBt6wr5RRmk=";
45 # Locations of nvidia driver libraries are not resolved via ldconfig which
46 # doesn't get used on NixOS.
47 (replaceVars ./0001-ldcache-don-t-use-ldcache.patch {
48 inherit (addDriverRunpath) driverLink;
51 # Use both PATH and the legacy nvidia-docker paths (NixOS artifacts)
53 # TODO: Remove the legacy compatibility once nvidia-docker is removed
55 ./0002-nvc-nvidia-docker-compatible-binary-lookups.patch
57 # fix bogus struct declaration
58 ./0003-nvc-fix-struct-declaration.patch
63 -e 's/^REVISION ?=.*/REVISION = ${src.rev}/' \
64 -e 's/^COMPILER :=.*/COMPILER = $(CC)/' \
68 -e 's/^GIT_TAG ?=.*/GIT_TAG = ${version}/' \
69 -e 's/^GIT_COMMIT ?=.*/GIT_COMMIT = ${src.rev}/' \
72 mkdir -p deps/src/nvidia-modprobe-${modprobeVersion}
73 cp -r ${patchedModprobe}/* deps/src/nvidia-modprobe-${modprobeVersion}
77 touch nvidia-modprobe-${modprobeVersion}/.download_stamp
80 # 1. replace DESTDIR=$(DEPS_DIR) with empty strings to prevent copying
81 # things into deps/src/nix/store
82 # 2. similarly, remove any paths prefixed with DEPS_DIR
83 # 3. prevent building static libraries because we don't build static
85 # 4. prevent installation of static libraries because of step 3
86 # 5. prevent installation of libnvidia-container-go.so twice
88 -e 's#DESTDIR=\$(DEPS_DIR)#DESTDIR=""#g' \
89 -e 's#\$(DEPS_DIR)\$#\$#g' \
90 -e 's#all: shared static tools#all: shared tools#g' \
91 -e '/$(INSTALL) -m 644 $(LIB_STATIC) $(DESTDIR)$(libdir)/d' \
92 -e '/$(INSTALL) -m 755 $(libdir)\/$(LIBGO_SHARED) $(DESTDIR)$(libdir)/d'
95 enableParallelBuilding = true;
101 env.NIX_CFLAGS_COMPILE = toString [ "-I${lib.getInclude libtirpc}/include/tirpc" ];
103 "-L${lib.getLib libtirpc}/lib"
107 nativeBuildInputs = [
125 # we can't use the WITH_TIRPC=yes flag that exists in the Makefile for the
126 # same reason we patch out the static library use of libtirpc so we set the
128 "CFLAGS=-DWITH_TIRPC"
133 inherit (addDriverRunpath) driverLink;
134 libraryPath = lib.makeLibraryPath [
141 remove-references-to -t "${go}" $out/lib/libnvidia-container-go.so.${version}
142 wrapProgram $out/bin/nvidia-container-cli --prefix LD_LIBRARY_PATH : ${libraryPath}
144 disallowedReferences = [ go ];
147 homepage = "https://github.com/NVIDIA/libnvidia-container";
148 description = "NVIDIA container runtime library";
149 license = licenses.asl20;
150 platforms = platforms.linux;
151 mainProgram = "nvidia-container-cli";
152 maintainers = with maintainers; [