summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2015-04-10 22:41:55 +0200
committerBjørn Forsman <bjorn.forsman@gmail.com>2015-06-14 18:56:58 +0200
commit74d5adcb4d114e2d159d4ed4a5f0ef35352465a9 (patch)
treeca8b18006345d2d463c1919e1725881de7b386df /nixos
parentc72bbc5b8eb135d13fa38a5ad7754df19c8d7f66 (diff)
downloadnixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.tar
nixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.tar.gz
nixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.tar.bz2
nixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.tar.lz
nixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.tar.xz
nixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.tar.zst
nixlib-74d5adcb4d114e2d159d4ed4a5f0ef35352465a9.zip
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.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/modprobe.nix2
1 files changed, 1 insertions, 1 deletions
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";
 
   };