gpu driver linking fix
This commit is contained in:
@@ -65,19 +65,73 @@
|
|||||||
vulkan-loader
|
vulkan-loader
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
# wgpu dlopens the Vulkan loader and libEGL by soname, and those in turn
|
# wgpu dlopens the Vulkan loader and libEGL, which in turn dlopen the GPU
|
||||||
# dlopen the GPU vendor driver named in the ICD/vendor JSON. Nixpkgs' own
|
# vendor driver named in the ICD / EGL vendor JSON. Nixpkgs supplies the
|
||||||
# store paths cover the loaders but never the driver, which lives outside
|
# loaders but never the driver: that lives outside /nix/store, under
|
||||||
# /nix/store: under /run/opengl-driver on NixOS, under the distro's library
|
# /run/opengl-driver on NixOS and in the distro's library directory
|
||||||
# directory everywhere else. Without these the loader finds zero drivers and
|
# everywhere else. With no driver reachable the loaders enumerate nothing
|
||||||
# wgpu reports "Failed to create surface for any enabled backend: {}".
|
# and wgpu fails with "Failed to create surface for any enabled backend: {}".
|
||||||
# They go last so /nix/store still wins for everything else.
|
#
|
||||||
driverLibraries = [
|
# The host directories cannot simply go on LD_LIBRARY_PATH: it outranks the
|
||||||
"/run/opengl-driver/lib"
|
# binary's DT_RUNPATH, so the host's libc.so.6 / libgcc_s.so.1 would load
|
||||||
|
# into a process linked against the store's glibc and segfault on startup.
|
||||||
|
# Instead, link only the vendor driver objects into a private directory and
|
||||||
|
# expose that. Their remaining dependencies (libc, libX11, ...) then resolve
|
||||||
|
# against the already-loaded store libraries.
|
||||||
|
hostDriverGlobs = [
|
||||||
|
"libGLX_*.so*" # GLX vendor drivers (glvnd dispatch stays from the store)
|
||||||
|
"libEGL_*.so*"
|
||||||
|
"libGLESv1_CM_*.so*"
|
||||||
|
"libGLESv2_*.so*"
|
||||||
|
"libnvidia-*.so*"
|
||||||
|
"libcuda.so*"
|
||||||
|
"libvulkan_*.so*" # mesa's radv / anv, not the loader itself
|
||||||
|
"libgallium*.so*"
|
||||||
|
"*_dri.so"
|
||||||
|
"libdrm*.so*"
|
||||||
|
];
|
||||||
|
hostLibraryDirs = [
|
||||||
"/usr/lib/${pkgs.stdenv.hostPlatform.parsed.cpu.name}-linux-gnu"
|
"/usr/lib/${pkgs.stdenv.hostPlatform.parsed.cpu.name}-linux-gnu"
|
||||||
"/usr/lib64"
|
"/usr/lib64"
|
||||||
"/usr/lib"
|
"/usr/lib"
|
||||||
];
|
];
|
||||||
|
# Runs inside the wrapper, before exec.
|
||||||
|
collectHostDrivers = ''
|
||||||
|
if [ -d /run/opengl-driver/lib ]; then
|
||||||
|
export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/run/opengl-driver/lib"
|
||||||
|
elif [ -z "''${SLERM_NO_HOST_DRIVERS:-}" ]; then
|
||||||
|
slermCache="''${XDG_CACHE_HOME:-$HOME/.cache}/slerm/gpu-drivers"
|
||||||
|
slermStale=1
|
||||||
|
if [ -e "$slermCache/.stamp" ]; then
|
||||||
|
slermStale=0
|
||||||
|
for slermDir in ${lib.concatStringsSep " " hostLibraryDirs}; do
|
||||||
|
if [ -d "$slermDir" ] && [ "$slermDir" -nt "$slermCache/.stamp" ]; then
|
||||||
|
slermStale=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ "$slermStale" = 1 ]; then
|
||||||
|
slermTmp="$slermCache.$$"
|
||||||
|
rm -rf "$slermTmp" && mkdir -p "$slermTmp" || slermTmp=""
|
||||||
|
for slermDir in ${lib.concatStringsSep " " hostLibraryDirs}; do
|
||||||
|
[ -n "$slermTmp" ] && [ -d "$slermDir" ] || continue
|
||||||
|
for slermGlob in ${lib.concatStringsSep " " hostDriverGlobs}; do
|
||||||
|
for slermLib in "$slermDir"/$slermGlob; do
|
||||||
|
[ -e "$slermLib" ] || continue
|
||||||
|
ln -sfn "$slermLib" "$slermTmp/''${slermLib##*/}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
if [ -n "$slermTmp" ]; then
|
||||||
|
: > "$slermTmp/.stamp"
|
||||||
|
rm -rf "$slermCache" && mv "$slermTmp" "$slermCache" || rm -rf "$slermTmp"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
[ -d "$slermCache" ] &&
|
||||||
|
export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$slermCache"
|
||||||
|
unset slermCache slermStale slermTmp slermDir slermGlob slermLib
|
||||||
|
fi
|
||||||
|
'';
|
||||||
ghosttyEnv = {
|
ghosttyEnv = {
|
||||||
GHOSTTY_SOURCE_DIR = "${ghostty-src}";
|
GHOSTTY_SOURCE_DIR = "${ghostty-src}";
|
||||||
GHOSTTY_ZIG_SYSTEM_DIR = "${ghosttyDeps}";
|
GHOSTTY_ZIG_SYSTEM_DIR = "${ghosttyDeps}";
|
||||||
@@ -130,7 +184,7 @@
|
|||||||
postFixup = lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
|
postFixup = lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
|
||||||
wrapProgram "$out/bin/slerm" \
|
wrapProgram "$out/bin/slerm" \
|
||||||
--suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibraries} \
|
--suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibraries} \
|
||||||
--suffix LD_LIBRARY_PATH : ${lib.concatStringsSep ":" driverLibraries}
|
--run ${lib.escapeShellArg collectHostDrivers}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
@@ -161,7 +215,8 @@
|
|||||||
shellHook = ''
|
shellHook = ''
|
||||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/target/zig-global-cache"
|
export ZIG_GLOBAL_CACHE_DIR="$PWD/target/zig-global-cache"
|
||||||
${lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
|
${lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
|
||||||
export LD_LIBRARY_PATH="${lib.makeLibraryPath runtimeLibraries}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}:${lib.concatStringsSep ":" driverLibraries}"
|
export LD_LIBRARY_PATH="${lib.makeLibraryPath runtimeLibraries}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||||
|
${collectHostDrivers}
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -526,7 +526,7 @@ fn show_pane(
|
|||||||
rect,
|
rect,
|
||||||
0,
|
0,
|
||||||
Stroke::new(
|
Stroke::new(
|
||||||
1.0,
|
1.0_f32,
|
||||||
if active {
|
if active {
|
||||||
accent
|
accent
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-3
@@ -63,7 +63,7 @@ fn powerline_shape(text: &str, rect: Rect, color: Color32) -> Option<egui::Shape
|
|||||||
Some(if filled {
|
Some(if filled {
|
||||||
egui::Shape::convex_polygon(points, color, Stroke::NONE)
|
egui::Shape::convex_polygon(points, color, Stroke::NONE)
|
||||||
} else {
|
} else {
|
||||||
egui::Shape::line(points, Stroke::new(1.0, color))
|
egui::Shape::line(points, Stroke::new(1.0_f32, color))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ impl Renderer {
|
|||||||
if enabled {
|
if enabled {
|
||||||
foregrounds.push(egui::Shape::line_segment(
|
foregrounds.push(egui::Shape::line_segment(
|
||||||
[pos + vec2(0.0, height), pos + vec2(cell.x, height)],
|
[pos + vec2(0.0, height), pos + vec2(cell.x, height)],
|
||||||
Stroke::new(1.0, fg),
|
Stroke::new(1.0_f32, fg),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ impl Renderer {
|
|||||||
painter.rect_stroke(
|
painter.rect_stroke(
|
||||||
cursor_rect,
|
cursor_rect,
|
||||||
0,
|
0,
|
||||||
Stroke::new(if active { 1.5 } else { 0.75 }, c),
|
Stroke::new(if active { 1.5_f32 } else { 0.75_f32 }, c),
|
||||||
egui::StrokeKind::Inside,
|
egui::StrokeKind::Inside,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user