From 74d5adcb4d114e2d159d4ed4a5f0ef35352465a9 Mon Sep 17 00:00:00 2001 From: Bjørn Forsman Date: Fri, 10 Apr 2015 22:41:55 +0200 Subject: nixos: move environment.{variables => sessionVariables}.MODULE_DIR This solves the problem that modprobe does not know about $MODULE_DIR when run via sudo, and instead wrongly tries to read /lib/modules/: $ sudo strace -efile modprobe foo |& grep modules open("/lib/modules/3.14.37/modules.softdep", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/modules/3.14.37/modules.dep.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/modules/3.14.37/modules.dep.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/modules/3.14.37/modules.alias.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) Without this patch, one would have to use sudo -E (preserves environment vars). But that option is reserved for sudo users with extra rights (SETENV), so it's not a solution. environment.sessionVariables are set by PAM, so they are included in the environment used by sudo. --- nixos/modules/system/boot/modprobe.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/system/boot/modprobe.nix b/nixos/modules/system/boot/modprobe.nix index a1feaad6132d..a3b616ff3eff 100644 --- a/nixos/modules/system/boot/modprobe.nix +++ b/nixos/modules/system/boot/modprobe.nix @@ -101,7 +101,7 @@ with lib; echo ${config.system.sbin.modprobe}/sbin/modprobe > /proc/sys/kernel/modprobe ''; - environment.variables.MODULE_DIR = "/run/current-system/kernel-modules/lib/modules"; + environment.sessionVariables.MODULE_DIR = "/run/current-system/kernel-modules/lib/modules"; }; -- cgit 1.4.1