From fcea5552224a7176f310c4a3cfa36bfd1045397b Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Fri, 2 Apr 2021 22:52:36 +0200 Subject: [PATCH] ddcutil: use nixos paths for kernel modules --- pkgs/tools/misc/ddcutil/default.nix | 5 ++++ pkgs/tools/misc/ddcutil/nixos-paths.diff | 32 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 pkgs/tools/misc/ddcutil/nixos-paths.diff diff --git a/pkgs/tools/misc/ddcutil/default.nix b/pkgs/tools/misc/ddcutil/default.nix index 1e2efc7f9cd3..1717b88f194a 100644 --- a/pkgs/tools/misc/ddcutil/default.nix +++ b/pkgs/tools/misc/ddcutil/default.nix @@ -12,6 +12,11 @@ stdenv.mkDerivation rec { sha256 = "sha256-F/tKW81bAyYtwpxhl5XC8YyMB+6S0XmqqigwJY2WFDU="; }; + patches = [ + # Look for kernel modules in /run/booted-system/kernel-modules/lib/modules/* + ./nixos-paths.diff + ]; + nativeBuildInputs = [ autoreconfHook pkg-config ]; buildInputs = [ i2c-tools udev libgudev diff --git a/pkgs/tools/misc/ddcutil/nixos-paths.diff b/pkgs/tools/misc/ddcutil/nixos-paths.diff new file mode 100644 index 000000000000..e45eb88b5190 --- /dev/null +++ b/pkgs/tools/misc/ddcutil/nixos-paths.diff @@ -0,0 +1,32 @@ +diff --git a/src/app_sysenv/query_sysenv_modules.c b/src/app_sysenv/query_sysenv_modules.c +index 59df64f1..fb244dd0 100644 +--- a/src/app_sysenv/query_sysenv_modules.c ++++ b/src/app_sysenv/query_sysenv_modules.c +@@ -50,7 +50,9 @@ bool is_module_loadable(char * module_name, int depth) { + g_snprintf(module_name_ko, 100, "%s.ko", module_name); + + char dirname[PATH_MAX]; +- g_snprintf(dirname, PATH_MAX, "/lib/modules/%s/kernel/drivers/i2c", utsbuf.release); ++ g_snprintf(dirname, PATH_MAX, ++ "/run/booted-system/kernel-modules/lib/modules/%s/kernel/drivers/i2c", ++ utsbuf.release); + + struct dirent *dent; + DIR *d; +diff --git a/src/util/linux_util.c b/src/util/linux_util.c +index 5eb8491c..3a129ccf 100644 +--- a/src/util/linux_util.c ++++ b/src/util/linux_util.c +@@ -29,8 +29,10 @@ bool is_module_builtin(char * module_name) + int rc = uname(&utsbuf); + assert(rc == 0); + +- char modules_builtin_fn[100]; +- snprintf(modules_builtin_fn, 100, "/lib/modules/%s/modules.builtin", utsbuf.release); ++ char modules_builtin_fn[PATH_MAX]; ++ snprintf(modules_builtin_fn, PATH_MAX, ++ "/run/booted-system/kernel-modules/lib/modules/%s/modules.builtin", ++ utsbuf.release); + + char ko_name[40]; + snprintf(ko_name, 40, "%s.ko", module_name);