python312Packages.llama-index: 0.12.9 -> 0.12.9.post1 (#371957)
[NixPkgs.git] / pkgs / by-name / li / libnvidia-container / 0002-nvc-nvidia-docker-compatible-binary-lookups.patch
blob2a52ad2bd2404ff5cc41726a856d1aa19ec0536f
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Moritz Sanft <58110325+msanft@users.noreply.github.com>
3 Date: Fri, 20 Dec 2024 16:37:07 +0100
4 Subject: [PATCH] nvc: nvidia-docker-compatible binary lookups
6 This patch maintains compatibility with NixOS' `virtualisation.docker.enableNvidia` option (which is to be removed soon), while also enabling supplying a custom PATH, to work with the modern CDI-based approach.
7 ---
8 src/nvc_info.c | 16 ++++++++++++++--
9 1 file changed, 14 insertions(+), 2 deletions(-)
11 diff --git a/src/nvc_info.c b/src/nvc_info.c
12 index cf4b1905fd2127c28ee16649501be122d3be5261..2ab552860ef98879b76398a6f9be95f07b2c8a4a 100644
13 --- a/src/nvc_info.c
14 +++ b/src/nvc_info.c
15 @@ -243,16 +243,28 @@ static int
16 find_binary_paths(struct error *err, struct dxcore_context* dxcore, struct nvc_driver_info* info,
17 const char *root, const char * const bins[], size_t size)
19 - char *env, *ptr;
20 + char *env, *ptr, *os_path;
21 const char *dir;
22 char tmp[PATH_MAX];
23 char path[PATH_MAX];
24 int rv = -1;
26 - if ((env = secure_getenv("PATH")) == NULL) {
27 + if ((os_path = secure_getenv("PATH")) == NULL) {
28 error_setx(err, "environment variable PATH not found");
29 return (-1);
32 + // TODO: Remove this patch once `virtualisation.docker.enableNvidia` is removed from NixOS.
33 + // It only exists to maintain compatibility with the old nvidia-docker package.
34 + int p_rv = snprintf(env, PATH_MAX, "/run/nvidia-docker/bin:/run/nvidia-docker/extras/bin:%s", os_path);
35 + if (p_rv >= PATH_MAX) {
36 + error_setx(err, "PATH environment variable too long");
37 + return (-1);
38 + } else if (p_rv < 0) {
39 + error_setx(err, "error setting PATH environment variable");
40 + return (-1);
41 + }
43 if ((env = ptr = xstrdup(err, env)) == NULL)
44 return (-1);