Skip to content

Commit 12d4ee7

Browse files
jmbaurdanielfullmer
authored andcommitted
Update nvidia-ctk and use RUNTIME_DIRECTORY when calling nvidia-ctk
Updates nvidia-ctk since some patches were applied upstream. Also changes the systemd service to use RUNTIME_DIRECTORY (this is what upstream nixpkgs does when they call nvidia-ctk).
1 parent e17355e commit 12d4ee7

File tree

2 files changed

+29
-36
lines changed

2 files changed

+29
-36
lines changed

modules/default.nix

+15-17
Original file line numberDiff line numberDiff line change
@@ -242,30 +242,28 @@ in
242242
otaUtils # Tools for UEFI capsule updates
243243
];
244244

245-
systemd.tmpfiles.rules = lib.optional nvidiaContainerRuntimeActive "d /var/run/cdi 0755 root root - -";
246-
247245
systemd.services.nvidia-cdi-generate = {
248246
enable = nvidiaContainerRuntimeActive;
249247
serviceConfig = {
250248
Type = "oneshot";
251249
RemainAfterExit = true;
252-
ExecStart =
253-
let
254-
exe = "${pkgs.nvidia-jetpack.nvidia-ctk}/bin/nvidia-ctk";
255-
in
256-
toString [
257-
exe
258-
"cdi"
259-
"generate"
260-
"--nvidia-ctk-path=${exe}" # it is odd that this is needed, should be the same as /proc/self/exe?
261-
"--driver-root=${pkgs.nvidia-jetpack.containerDeps}" # the root where nvidia libs will be resolved from
262-
"--dev-root=/" # the root where chardevs will be resolved from
263-
"--mode=csv"
264-
"--csv.file=${pkgs.nvidia-jetpack.l4tCsv}"
265-
"--output=/var/run/cdi/jetpack-nixos" # a yaml file extension is added by the nvidia-ctk tool
266-
];
250+
RuntimeDirectory = "cdi";
267251
};
268252
wantedBy = [ "multi-user.target" ];
253+
script =
254+
let
255+
exe = lib.getExe pkgs.nvidia-jetpack.nvidia-ctk;
256+
in
257+
''
258+
${exe} cdi generate \
259+
--nvidia-ctk-path=${exe} \
260+
--driver-root=${pkgs.nvidia-jetpack.containerDeps} \
261+
--ldconfig-path ${lib.getExe' pkgs.glibc "ldconfig"} \
262+
--dev-root=/ \
263+
--mode=csv \
264+
--csv.file=${pkgs.nvidia-jetpack.l4tCsv} \
265+
--output="$RUNTIME_DIRECTORY/jetpack-nixos"
266+
'';
269267
};
270268

271269
# Used by libEGL_nvidia.so.0

pkgs/containers/nvidia-ctk.nix

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
{ fetchFromGitLab, buildGoModule, fetchpatch }:
1+
{ buildGoModule, fetchFromGitHub, fetchpatch }:
22

33
buildGoModule rec {
44
pname = "nvidia-ctk";
5-
version = "unstable-${builtins.substring 0 7 src.rev}";
5+
version = "1.15.0-rc.4";
66

77
# TODO(jared): pin to v1.15.0 once it is released
88
# We currently rely on some features in an unreleased version of nvidia
99
# container toolkit.
10-
src = fetchFromGitLab {
10+
src = fetchFromGitHub {
1111
owner = "nvidia";
12-
repo = "container-toolkit/container-toolkit";
13-
rev = "a2262d00cc6d98ac2e95ae2f439e699a7d64dc17";
14-
hash = "sha256-Oi04PIES0qTih/EiFBStIoBadM3H52+81KEfUumQcIs=";
12+
repo = "nvidia-container-toolkit";
13+
rev = "v${version}";
14+
hash = "sha256-Ky0mGothIq5BOAHc4ujrMrh1niBYUoSgaRnv30ymjsE=";
1515
};
1616

1717
patches = [
1818
# ensure nvidia-ctk can build with Go versions less than 1.20 (currently
1919
# required on their latest release)
2020
(fetchpatch {
21-
name = "Fix-double-error-wrap-fmt";
22-
url = "https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/commit/80756d00a6b75761103c50f605cece5fa7e39392.patch";
23-
hash = "sha256-hoeMUUPWKToCR7V/JG26wF6SCoHQwQORcGimH6EXDJ8=";
24-
})
25-
(fetchpatch {
26-
name = "Use-golang-1.17";
27-
url = "https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/commit/5956b04096d1a92b241b13cc1f3e208f8b99eea0.patch";
28-
hash = "sha256-VB3+ijc2Pdlm1W2LqvCjx9KDYKinWBkr/eiUJEwig/o=";
21+
name = "Add-errors-Join-wrapper";
22+
url = "https://github.com/NVIDIA/nvidia-container-toolkit/commit/92f17e94939bf8c213419749f5f7b48d2f0e618c.patch";
23+
hash = "sha256-ioWstYky7LbIGtlfMMlbhIVN8yH7Qgp3z4wrkytT3TY=";
2924
})
3025
(fetchpatch {
31-
name = "Draft-Compat-with-golang-1.17";
32-
url = "https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/commit/86f68a49014a4cffb7dcb51f14a02f6f1816b2ee.patch";
33-
hash = "sha256-ioWstYky7LbIGtlfMMlbhIVN8yH7Qgp3z4wrkytT3TY=";
26+
name = "Fix-double-error-wrap-fmt";
27+
url = "https://github.com/NVIDIA/nvidia-container-toolkit/commit/f23fd2ce38ee3a9e87ac41c265b637cf97990ac7.patch";
28+
hash = "sha256-hoeMUUPWKToCR7V/JG26wF6SCoHQwQORcGimH6EXDJ8=";
3429
})
35-
# ensure nvidia-ctk can find ldconfig
36-
./nixos-ldconfig.patch
3730
];
3831

3932
subPackages = [ "cmd/nvidia-ctk" ];
4033

4134
vendorHash = null;
4235

4336
ldflags = [ "-s" "-w" "-extldflags=-Wl,-z,lazy" ];
37+
38+
meta.mainProgram = "nvidia-ctk";
4439
}

0 commit comments

Comments
 (0)