* Use boot.kernelModules everywhere instead of explicit calls to

modprobe.
* Move the implementation of boot.kernelModules from the udev job to
  the activation script.  This prevents races with the udev job.
* Drop references to the "capability" kernel module, which no longer
  exists.

svn path=/nixos/trunk/; revision=33208
wip/yesman
Eelco Dolstra 12 years ago
parent 646d67465c
commit 573877c1ac
  1. 2
      modules/config/power-management.nix
  2. 23
      modules/hardware/cpu/intel-microcode.nix
  3. 11
      modules/services/audio/alsa.nix
  4. 11
      modules/services/hardware/udev.nix
  5. 15
      modules/services/misc/autofs.nix
  6. 9
      modules/services/networking/ddclient.nix
  7. 9
      modules/services/networking/dhclient.nix
  8. 8
      modules/services/networking/ntpd.nix
  9. 2
      modules/services/networking/portmap.nix
  10. 8
      modules/services/networking/privoxy.nix
  11. 2
      modules/services/printing/cupsd.nix
  12. 6
      modules/services/security/tor.nix
  13. 8
      modules/services/system/cgroups.nix
  14. 9
      modules/services/system/uptimed.nix
  15. 5
      modules/system/boot/modprobe.nix

@ -88,7 +88,7 @@ in
boot.kernelModules =
[ "acpi_cpufreq" "cpufreq_performance" "cpufreq_powersave" "cpufreq_ondemand"
"p4_clockmod" "cpufreq_conservative"
"cpufreq_conservative"
];
powerManagement.cpuFreqGovernor = mkDefault "ondemand";

@ -1,4 +1,6 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
{
@ -6,11 +8,11 @@
options = {
hardware.cpu.intel.updateMicrocode = pkgs.lib.mkOption {
hardware.cpu.intel.updateMicrocode = mkOption {
default = false;
type = pkgs.lib.types.bool;
type = types.bool;
description = ''
Update the CPU microcode for intel processors.
Update the CPU microcode for Intel processors.
'';
};
@ -19,16 +21,9 @@
###### implementation
config = pkgs.lib.mkIf config.hardware.cpu.intel.updateMicrocode {
hardware.firmware = [pkgs.microcodeIntel];
jobs.microcode = {
name = "microcode";
description = "load microcode";
startOn = "started udev";
exec = "modprobe microcode";
path = [config.system.sbin.modprobe];
task = true;
};
config = mkIf config.hardware.cpu.intel.updateMicrocode {
hardware.firmware = [ pkgs.microcodeIntel ];
boot.kernelModules = [ "microcode" ];
};
}

@ -45,6 +45,8 @@ in
environment.systemPackages = [ alsaUtils ];
boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";
jobs.alsa =
{ startOn = "stopped udevtrigger";
@ -52,15 +54,6 @@ in
''
mkdir -m 0755 -p $(dirname ${soundState})
# Load some additional modules.
${optionalString config.sound.enableOSSEmulation
''
for mod in snd_pcm_oss; do
${config.system.sbin.modprobe}/sbin/modprobe $mod || true
done
''
}
# Restore the sound state.
${alsaUtils}/sbin/alsactl -f ${soundState} restore || true
'';

@ -14,8 +14,6 @@ let
destination = "/etc/udev/rules.d/10-local.rules";
};
modprobe = config.system.sbin.modprobe;
nixosRules = ''
# Miscellaneous devices.
@ -54,7 +52,7 @@ let
# Fix some paths in the standard udev rules. Hacky.
for i in $out/*.rules; do
substituteInPlace $i \
--replace \"/sbin/modprobe \"${modprobe}/sbin/modprobe \
--replace \"/sbin/modprobe \"${config.system.sbin.modprobe}/sbin/modprobe \
--replace \"/sbin/mdadm \"${pkgs.mdadm}/sbin/mdadm \
--replace \"/sbin/blkid \"${pkgs.utillinux}/sbin/blkid \
--replace \"/bin/mount \"${pkgs.utillinux}/bin/mount
@ -232,13 +230,6 @@ in
mkdir -p /var/lib/udev/rules.d
touch /var/lib/udev/rules.d/70-persistent-cd.rules /var/lib/udev/rules.d/70-persistent-net.rules
# Do the loading of additional stage 2 kernel modules.
# Maybe this isn't the best place...
for i in ${toString config.boot.kernelModules}; do
echo "Loading kernel module $i..."
${modprobe}/sbin/modprobe $i || true
done
mkdir -p /dev/.udev # !!! bug in udev?
'';

@ -50,11 +50,6 @@ in
";
};
kernelModules = mkOption {
default = ["fuse"];
description="kernel modules to load";
};
timeout = mkOption {
default = 600;
description = "Set the global minimum timeout, in seconds, until directories are unmounted";
@ -81,19 +76,15 @@ in
source = pkgs.writeText "auto.master" cfg.autoMaster;
};
boot.kernelModules = [ "autofs4" ];
jobs.autofs =
{ description = "Filesystem automounter";
startOn = "started network-interfaces";
stopOn = "stopping network-interfaces";
environment =
{ PATH = "${pkgs.nfsUtils}/sbin:${config.system.sbin.modprobe}/sbin:${pkgs.sshfsFuse}/sbin:${pkgs.sshfsFuse}/bin:$PATH";
};
preStart =
pkgs.lib.concatMapStrings (module : "modprobe ${module} || true\n")
(["autofs4"] ++ cfg.kernelModules);
path = [ pkgs.nfsUtils pkgs.sshfsFuse ];
preStop =
''

@ -10,8 +10,6 @@ let
ddclientUser = "ddclient";
modprobe = config.system.sbin.modprobe;
ddclientFlags = "-foreground -file ${ddclientCfg}";
ddclientCfg = pkgs.writeText "ddclient.conf" ''
@ -89,8 +87,7 @@ in
web = mkOption {
default = "web, web=checkip.dyndns.com/, web-skip='IP Address'" ;
description = ''
'';
description = "";
};
};
@ -101,6 +98,7 @@ in
###### implementation
config = mkIf config.services.ddclient.enable {
environment.systemPackages = [ ddclient ];
users.extraUsers = singleton
@ -119,9 +117,6 @@ in
''
mkdir -m 0755 -p ${stateDir}
chown ${ddclientUser} ${stateDir}
# Needed to run ddclient as an unprivileged user.
${modprobe}/sbin/modprobe capability || true
'';
exec = "${ddclient}/bin/ddclient ${ddclientFlags}";

@ -44,18 +44,15 @@ in
config = mkIf config.networking.useDHCP {
# dhclient barfs if /proc/net/if_inet6 doesn't exist.
boot.kernelModules = [ "ipv6" ];
jobs.dhclient =
{ startOn = "started network-interfaces";
stopOn = "stopping network-interfaces";
path = [ dhcp ];
preStart =
''
# dhclient barfs if /proc/net/if_inet6 doesn't exist.
${config.system.sbin.modprobe}/sbin/modprobe ipv6 || true
'';
script =
''
# Determine the interface on which to start dhclient.

@ -10,16 +10,12 @@ let
ntpUser = "ntp";
servers = config.services.ntp.servers;
modprobe = config.system.sbin.modprobe;
configFile = pkgs.writeText "ntp.conf" ''
# Keep the drift file in ${stateDir}/ntp.drift. However, since we
# chroot to ${stateDir}, we have to specify it as /ntp.drift.
driftfile /ntp.drift
${toString (map (server: "server " + server + " iburst\n") servers)}
${toString (map (server: "server " + server + " iburst\n") config.services.ntp.servers)}
'';
ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup -i ${stateDir}";
@ -69,8 +65,6 @@ in
home = stateDir;
};
boot.kernelModules = [ "capability" ];
jobs.ntpd =
{ description = "NTP daemon";

@ -68,7 +68,7 @@ in
jobs.portmap =
{ description = "ONC RPC portmap";
startOn = "started network-interfaces";
startOn = "startup";
stopOn = "never";
daemonType = "fork"; # needed during shutdown

@ -10,8 +10,6 @@ let
privoxyUser = "privoxy";
modprobe = config.system.sbin.modprobe;
privoxyFlags = "--no-daemon --user ${privoxyUser} ${privoxyCfg}";
privoxyCfg = pkgs.writeText "privoxy.conf" ''
@ -68,12 +66,13 @@ in
###### implementation
config = mkIf config.services.privoxy.enable {
environment.systemPackages = [ privoxy ];
users.extraUsers = singleton
{ name = privoxyUser;
uid = config.ids.uids.privoxy;
description = "privoxy daemon user";
description = "Privoxy daemon user";
home = stateDir;
};
@ -86,9 +85,6 @@ in
''
mkdir -m 0755 -p ${stateDir}
chown ${privoxyUser} ${stateDir}
# Needed to run privoxy as an unprivileged user.
${modprobe}/sbin/modprobe capability || true
'';
exec = "${privoxy}/sbin/privoxy ${privoxyFlags}";

@ -8,8 +8,6 @@ let
logDir = "/var/log/cups";
modprobe = config.system.sbin.modprobe;
cfg = config.services.printing;
additionalBackends = pkgs.stdenv.mkDerivation {

@ -9,14 +9,13 @@ let
stateDir = "/var/lib/tor";
privoxyDir = stateDir+"/privoxy";
modprobe = config.system.sbin.modprobe;
cfg = config.services.tor;
torUser = "tor";
opt = name: value: if value != "" then "${name} ${value}" else "";
optint = name: value: if value != 0 then "${name} ${toString value}" else "";
in
{
@ -251,9 +250,6 @@ in
preStart = ''
mkdir -m 0755 -p ${privoxyDir}
chown ${torUser} ${privoxyDir}
# Needed to run privoxy as an unprivileged user?
${modprobe}/sbin/modprobe capability || true
'';
exec = "${privoxy}/sbin/privoxy --no-daemon --user ${torUser} ${pkgs.writeText "torPrivoxy.conf" cfg.client.privoxy.config}";
}; };

@ -96,6 +96,10 @@ in
}
];
# The daemon requires the userspace<->kernelspace netlink
# connector.
boot.kernelModules = [ "cn" ];
jobs.cgroups =
{ startOn = "startup";
@ -105,10 +109,6 @@ in
preStart =
''
# The daemon requires the userspace<->kernelspace netlink
# connector.
${config.system.sbin.modprobe}/sbin/modprobe cn || true
cgclear || true
# Mount the cgroup hierarchies. Note: we refer to the

@ -10,10 +10,6 @@ let
uptimedUser = "uptimed";
modprobe = config.system.sbin.modprobe;
uptimedFlags = "";
in
{
@ -59,15 +55,12 @@ in
mkdir -m 0755 -p ${stateDir}
chown ${uptimedUser} ${stateDir}
# Needed to run uptimed as an unprivileged user.
${modprobe}/sbin/modprobe capability || true
if ! test -f ${stateDir}/bootid ; then
${uptimed}/sbin/uptimed -b
fi
'';
exec = "${uptimed}/sbin/uptimed ${uptimedFlags}";
exec = "${uptimed}/sbin/uptimed";
};
};

@ -100,6 +100,11 @@ with pkgs.lib;
# We need this when the kernel (or some module) auto-loads a
# module.
echo ${config.system.sbin.modprobe}/sbin/modprobe > /proc/sys/kernel/modprobe
# Do the loading of additional stage 2 kernel modules.
for i in ${toString config.boot.kernelModules}; do
${config.system.sbin.modprobe}/sbin/modprobe $i || true
done
'';
};

Loading…
Cancel
Save