summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Picciano <me@mediocregopher.com>2024-06-17 12:43:47 +0200
committerBrian Picciano <me@mediocregopher.com>2024-06-17 12:43:47 +0200
commit698b92d7fb26680ebb0328c5c6c985071ff79a0a (patch)
treeb51e7b3dff0053503a2b6bdad789f3a17a07f969
parent4576644b8f37f71fe82c51e95d1dc06615ef5f14 (diff)
Fix X server not picking up system library files
-rw-r--r--alacritty/default.nix17
-rw-r--r--awesome/default.nix12
-rw-r--r--nix/ld-utils.nix22
-rw-r--r--nix/nixgl.nix14
-rw-r--r--pkgs.nix18
5 files changed, 55 insertions, 28 deletions
diff --git a/alacritty/default.nix b/alacritty/default.nix
index e9a955d..9350884 100644
--- a/alacritty/default.nix
+++ b/alacritty/default.nix
@@ -57,27 +57,20 @@
alacritty = pkgs.writeShellScriptBin "alacritty" ''
set -e -x
- host_ld_lib_path="$(
- ldconfig -v 2>/dev/null \
- | grep -v ^$'\t' \
- | tr -s ':\n' ':' \
- | head -c-1 \
- )"
+ source "${pkgs.ldUtils}"
- bin_ld_lib_path="$(
- objdump -x ${pkgs.alacritty}/bin/alacritty \
- | grep "RUNPATH" \
- | awk '{print $2}' \
- )"
+ host_ld_lib_path="$(host_ld_lib_path)"
host_dri_path="$(
- echo "$host_ld_lib_path" \
+ echo "$host_lib_path" \
| tr -s ':' '\n' \
| while read d; do if [ -d "$d/dri" ]; then echo "$d"/dri; fi; done \
| tr '\n' ':' \
| head -c-1
)"
+ bin_ld_lib_path="$(bin_ld_lib_path "${pkgs.alacritty}/bin/alacritty")"
+
# overwrite LD_LIBRARY_PATH such that the binary's ld search path is still
# searched first, but afterwards the host's ld search path is looked
# through. Similarly, the dri paths are set to be the hosts. This allows us
diff --git a/awesome/default.nix b/awesome/default.nix
index ca61ec5..acc6375 100644
--- a/awesome/default.nix
+++ b/awesome/default.nix
@@ -64,6 +64,10 @@ EOF
set -e -x
+ # Set during startup of X server, but we don't want it inherited by
+ # everything downstream.
+ unset LD_LIBRARY_PATH
+
# Turn off powersaving (fuck the environment)
${pkgs.xorg.xset}/bin/xset -dpms
${pkgs.xorg.xset}/bin/xset s off
@@ -103,6 +107,14 @@ EOF
awesome = pkgs.writeShellScriptBin "awesome" ''
export XORGCONFIG=${xorgConf}
+
+ # set the LD_LIBRARY_PATH to search both the libraries needed by X, but also
+ # those on the host, so that the video driver has access to them if it needs
+ # it.
+ source "${pkgs.ldUtils}"
+ x_ld_lib_path="$(bin_ld_lib_path "${pkgs.xorg.xinit}/bin/xinit")"
+ export LD_LIBRARY_PATH="$x_ld_lib_path":"$(host_ld_lib_path)"
+
exec startx ${awesomeInner}
'';
diff --git a/nix/ld-utils.nix b/nix/ld-utils.nix
new file mode 100644
index 0000000..6201b63
--- /dev/null
+++ b/nix/ld-utils.nix
@@ -0,0 +1,22 @@
+# ld-utils is a collection of functions which are intended to be sourced into
+# other scripts
+pkgs: pkgs.writeShellScript "ld-utils.sh" ''
+
+# returns the colon-delimited LD_LIBRARY_PATH for host installed libraries, as
+# determined by ldconfig.
+function host_ld_lib_path {
+ ldconfig -v 2>/dev/null \
+ | grep -v ^$'\t' \
+ | cut -d':' -f1 \
+ | tr -s ':\n' ':' \
+ | head -c-1
+}
+
+# bin_ld_lib_path returns the colon-delimited LD_LIBRARY_PATH which is embedded
+# into a particular binary as its RUNPATH.
+function bin_ld_lib_path {
+ objdump -x "$1" \
+ | grep "RUNPATH" \
+ | awk '{print $2}'
+}
+''
diff --git a/nix/nixgl.nix b/nix/nixgl.nix
new file mode 100644
index 0000000..82dbdfd
--- /dev/null
+++ b/nix/nixgl.nix
@@ -0,0 +1,14 @@
+pkgs: let
+
+ src = builtins.fetchTarball {
+ name = "nixgl-unstable";
+ url = "https://github.com/guibou/nixGL/archive/7165ffbccbd2cf4379b6cd6d2edd1620a427e5ae.tar.gz";
+ sha256 = "1wc85xqnq2wb008y9acb29jbfkc242m9697g2b8j6q3yqmfhrks1";
+ };
+
+ nixgl = (import src) {
+ inherit pkgs;
+ enable32bits = false;
+ };
+
+in nixgl.auto.nixGLDefault
diff --git a/pkgs.nix b/pkgs.nix
index 72dca4d..f7a3f55 100644
--- a/pkgs.nix
+++ b/pkgs.nix
@@ -7,22 +7,8 @@ rec {
config = {
allowUnfree = true;
packageOverrides = pkgs: {
-
- nixgl = let
-
- src = builtins.fetchTarball {
- name = "nixgl-unstable";
- url = "https://github.com/guibou/nixGL/archive/7165ffbccbd2cf4379b6cd6d2edd1620a427e5ae.tar.gz";
- sha256 = "1wc85xqnq2wb008y9acb29jbfkc242m9697g2b8j6q3yqmfhrks1";
- };
-
- nixgl = (import src) {
- inherit pkgs;
- enable32bits = false;
- };
-
- in nixgl.auto.nixGLDefault;
-
+ nixgl = (import ./nix/nixgl.nix) pkgs;
+ ldUtils = (import ./nix/ld-utils.nix) pkgs;
};
};