7 maintainers = [ maintainers.joachifm ];
11 security.lockKernelModules = mkOption {
15 Disable kernel module loading once the system is fully initialised.
16 Module loading is disabled until the next reboot. Problems caused
17 by delayed module loading can be fixed by adding the module(s) in
18 question to {option}`boot.kernelModules`.
23 config = mkIf config.security.lockKernelModules {
24 boot.kernelModules = concatMap (x:
25 optionals (x.device != null) (
27 then [ "vfat" "nls-cp437" "nls-iso8859-1" ]
29 ) config.system.build.fileSystems;
31 systemd.services.disable-kernel-module-loading = {
32 description = "Disable kernel module loading";
34 wants = [ "systemd-udevd.service" ];
35 wantedBy = [ config.systemd.defaultUnit ];
39 "systemd-modules-load.service"
40 config.systemd.defaultUnit
43 unitConfig.ConditionPathIsReadWrite = "/proc/sys/kernel";
47 RemainAfterExit = true;
52 ${config.systemd.package}/bin/udevadm settle
53 echo -n 1 >/proc/sys/kernel/modules_disabled