push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
From e4449f06a8989ff22947309151855b388c311aed Mon Sep 17 00:00:00 2001
From: Jared Baur <jaredbaur@fastmail.com>
Date: Mon, 22 Jan 2024 20:42:48 -0800
Subject: [PATCH] Add dlopen discoverer
---
internal/lookup/dlopen.go | 57 ++++++++++++++++++++++++++++++++++++++
internal/lookup/library.go | 3 ++
2 files changed, 60 insertions(+)
create mode 100644 internal/lookup/dlopen.go
diff --git a/internal/lookup/dlopen.go b/internal/lookup/dlopen.go
new file mode 100644
index 00000000..7cd84522
--- /dev/null
+++ b/internal/lookup/dlopen.go
@@ -0,0 +1,57 @@
+package lookup
+
+// #cgo LDFLAGS: -ldl
+// #define _GNU_SOURCE
+// #include <dlfcn.h>
+// #include <stdlib.h>
+import "C"
+
+import (
+ "fmt"
+ "path/filepath"
+ "unsafe"
+)
+
+// dlopenLocator can be used to locate libraries given a system's dynamic
+// linker.
+type dlopenLocator struct {
+ file
+}
+
+// NewDlopenLocator creats a locator that can be used for locating libraries
+// through the dlopen mechanism.
+func NewDlopenLocator(opts ...Option) Locator {
+ f := newFileLocator(opts...)
+ d := dlopenLocator{file: *f}
+ return &d
+}
+
+// Locate finds the specified pattern if the systems' dynamic linker can find
+// it via dlopen. Note that patterns with wildcard patterns will likely not be
+// found as it is uncommon for libraries to have wildcard patterns in their
+// file name.
+func (d dlopenLocator) Locate(pattern string) ([]string, error) {
+ libname := C.CString(pattern)
+ defer C.free(unsafe.Pointer(libname))
+
+ d.logger.Debugf("Calling dlopen for %s", pattern)
+
+ handle := C.dlopen(libname, C.RTLD_LAZY)
+ if handle == nil {
+ return nil, fmt.Errorf("dlopen %s failed", pattern)
+ }
+ defer C.dlclose(handle)
+
+ libParentPath := C.CString("")
+
+ d.logger.Debugf("Calling dlinfo on handle for %s", pattern)
+ ret := C.dlinfo(handle, C.RTLD_DI_ORIGIN, unsafe.Pointer(libParentPath))
+ if ret == -1 {
+ return nil, fmt.Errorf("dlinfo on handle for %s failed", pattern)
+ }
+
+ libAbsolutePath := filepath.Join(C.GoString(libParentPath), pattern)
+ d.logger.Debugf("Found library for %s at %s", pattern, libAbsolutePath)
+
+ return []string{libAbsolutePath}, nil
+}
diff --git a/internal/lookup/library.go b/internal/lookup/library.go
index 7f5cf7c8..916edde2 100644
--- a/internal/lookup/library.go
+++ b/internal/lookup/library.go
@@ -61,7 +61,10 @@ func NewLibraryLocator(opts ...Option) Locator {
// We construct a symlink locator for expected library locations.
symlinkLocator := NewSymlinkLocator(opts...)
+ dlopenLocator := NewDlopenLocator(opts...)
+
l := First(
+ dlopenLocator,
symlinkLocator,
newLdcacheLocator(opts...),
)
--

View File

@@ -0,0 +1,36 @@
{
stdenv,
lib,
fetchFromGitHub,
}:
stdenv.mkDerivation rec {
pname = "nvidia-docker";
version = "2.5.0";
src = fetchFromGitHub {
owner = "NVIDIA";
repo = "nvidia-docker";
rev = "v${version}";
hash = "sha256-kHzwFnN/DbpOe1sYDJkrRMxXE1bMiyuCPsbPGq07M9g=";
};
buildPhase = ''
mkdir bin
cp nvidia-docker bin
substituteInPlace bin/nvidia-docker --subst-var-by VERSION ${version}
'';
installPhase = ''
mkdir -p $out/bin
cp bin/nvidia-docker $out/bin
'';
meta = with lib; {
homepage = "https://github.com/NVIDIA/nvidia-docker";
description = "NVIDIA container runtime for Docker";
license = licenses.bsd3;
platforms = platforms.linux;
maintainers = with maintainers; [ cpcloud ];
};
}

View File

@@ -0,0 +1,102 @@
{
lib,
glibc,
fetchFromGitHub,
makeWrapper,
buildGoModule,
autoAddDriverRunpath,
}:
let
# From https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/03cbf9c6cd26c75afef8a2dd68e0306aace80401/Makefile#L54
cliVersionPackage = "github.com/NVIDIA/nvidia-container-toolkit/internal/info";
in
buildGoModule (finalAttrs: {
pname = "nvidia-container-toolkit";
version = "1.17.8";
src = fetchFromGitHub {
owner = "NVIDIA";
repo = "nvidia-container-toolkit";
tag = "v${finalAttrs.version}";
hash = "sha256-B17cPxdrQ8qMNgFh4XcDwwKryukMrn0GV2LNPHM7kBo=";
};
outputs = [
"out"
"tools"
];
vendorHash = null;
patches = [
# This patch causes library lookups to first attempt loading via dlopen
# before falling back to the regular symlink location and ldcache location.
./0001-Add-dlopen-discoverer.patch
];
postPatch = ''
substituteInPlace internal/config/config.go \
--replace-fail '/usr/bin/nvidia-container-runtime-hook' "$tools/bin/nvidia-container-runtime-hook" \
--replace-fail '/sbin/ldconfig' '${lib.getBin glibc}/sbin/ldconfig'
substituteInPlace tools/container/toolkit/toolkit.go \
--replace-fail '/sbin/ldconfig' '${lib.getBin glibc}/sbin/ldconfig'
substituteInPlace cmd/nvidia-cdi-hook/update-ldcache/update-ldcache.go \
--replace-fail '/sbin/ldconfig' '${lib.getBin glibc}/sbin/ldconfig'
'';
subPackages = [
"cmd/nvidia-cdi-hook"
"cmd/nvidia-container-runtime"
"cmd/nvidia-container-runtime.cdi"
"cmd/nvidia-container-runtime-hook"
"cmd/nvidia-container-runtime.legacy"
"cmd/nvidia-ctk"
];
# Based on upstream's Makefile:
# https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/03cbf9c6cd26c75afef8a2dd68e0306aace80401/Makefile#L64
ldflags = [
"-extldflags=-Wl,-z,lazy" # May be redunandant, cf. `man ld`: "Lazy binding is the default".
"-s" # "disable symbol table"
# "-X name=value"
"-X ${cliVersionPackage}.version=${finalAttrs.version}"
"-X ${cliVersionPackage}.gitCommit=${finalAttrs.src.rev}"
];
nativeBuildInputs = [
autoAddDriverRunpath
makeWrapper
];
checkFlags =
let
skippedTests = [
# Disable tests executing nvidia-container-runtime command.
"TestGoodInput"
"TestDuplicateHook"
];
in
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
postInstall = ''
mkdir -p $tools/bin
mv $out/bin/{nvidia-cdi-hook,nvidia-container-runtime,nvidia-container-runtime.cdi,nvidia-container-runtime-hook,nvidia-container-runtime.legacy} $tools/bin
'';
meta = {
homepage = "https://gitlab.com/nvidia/container-toolkit/container-toolkit";
description = "NVIDIA Container Toolkit";
mainProgram = "nvidia-ctk";
license = lib.licenses.asl20;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [
cpcloud
christoph-heiss
];
};
})

View File

@@ -0,0 +1,20 @@
{
lib,
newScope,
symlinkJoin,
}:
# Note this scope isn't recursed into, at the time of writing.
lib.makeScope newScope (self: {
nvidia-container-toolkit-docker = self.callPackage ./package.nix { };
nvidia-docker = symlinkJoin {
name = "nvidia-docker";
paths = [
self.nvidia-docker-unwrapped
self.nvidia-container-toolkit-docker
];
inherit (self.nvidia-docker-unwrapped) meta;
};
nvidia-docker-unwrapped = self.callPackage ./nvidia-docker.nix { };
})