mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-20 03:43:45 +00:00
* Let udev call modprobe to load modules for all known hardware. This
makes the `hardware-scan' job unnecessary. (In fact the new approach appears to be more thorough; it loads some drivers that were not previously loaded.) svn path=/nixos/trunk/; revision=12248
This commit is contained in:
parent
96cfd4105e
commit
5f60393ffe
@ -19,33 +19,32 @@ in
|
||||
}
|
||||
];
|
||||
|
||||
job = "
|
||||
start on hardware-scan
|
||||
stop on shutdown
|
||||
job = ''
|
||||
start on udev
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
start script
|
||||
|
||||
mkdir -m 0755 -p $(dirname ${soundState})
|
||||
mkdir -m 0755 -p $(dirname ${soundState})
|
||||
|
||||
# Load some additional modules.
|
||||
for mod in snd_pcm_oss; do
|
||||
${modprobe}/sbin/modprobe $mod || true
|
||||
done
|
||||
# Load some additional modules.
|
||||
for mod in snd_pcm_oss; do
|
||||
${modprobe}/sbin/modprobe $mod || true
|
||||
done
|
||||
|
||||
# Restore the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} restore
|
||||
# Restore the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} restore
|
||||
|
||||
end script
|
||||
end script
|
||||
|
||||
respawn sleep 1000000 # !!! hack
|
||||
respawn sleep 1000000 # !!! hack
|
||||
|
||||
stop script
|
||||
stop script
|
||||
|
||||
# Save the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} store
|
||||
# Save the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} store
|
||||
|
||||
end script
|
||||
|
||||
";
|
||||
end script
|
||||
'';
|
||||
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ let
|
||||
# The udev daemon creates devices nodes and runs programs when
|
||||
# hardware events occur.
|
||||
(import ../upstart-jobs/udev.nix {
|
||||
inherit modprobe;
|
||||
inherit (pkgs) stdenv writeText substituteAll udev procps;
|
||||
inherit (pkgs.lib) cleanSource;
|
||||
firmwareDirs =
|
||||
@ -115,13 +116,6 @@ let
|
||||
inherit (pkgs) mdadm;
|
||||
})
|
||||
|
||||
# Hardware scan; loads modules for PCI devices.
|
||||
(import ../upstart-jobs/hardware-scan.nix {
|
||||
inherit modprobe;
|
||||
doHardwareScan = config.boot.hardwareScan;
|
||||
kernelModules = config.boot.kernelModules;
|
||||
})
|
||||
|
||||
# Mount file systems.
|
||||
(import ../upstart-jobs/filesystems.nix {
|
||||
inherit (pkgs) utillinux e2fsprogs;
|
||||
|
@ -1,28 +0,0 @@
|
||||
{modprobe, doHardwareScan, kernelModules}:
|
||||
|
||||
{
|
||||
name = "hardware-scan";
|
||||
|
||||
job = ''
|
||||
start on udev
|
||||
|
||||
script
|
||||
for i in ${toString kernelModules}; do
|
||||
echo "Loading kernel module $i..."
|
||||
${modprobe}/sbin/modprobe $i || true
|
||||
done
|
||||
|
||||
if test -n "${toString doHardwareScan}" -a ! -e /var/run/safemode; then
|
||||
|
||||
# Try to load modules for all PCI and USB devices.
|
||||
for i in /sys/bus/pci/devices/*/modalias /sys/bus/usb/devices/*/modalias; do
|
||||
echo "Trying to load a module for $(basename $(dirname $i))..."
|
||||
${modprobe}/sbin/modprobe $(cat $i) || true
|
||||
echo ""
|
||||
done
|
||||
|
||||
fi
|
||||
end script
|
||||
'';
|
||||
|
||||
}
|
@ -16,86 +16,85 @@ in
|
||||
{
|
||||
name = "network-interfaces";
|
||||
|
||||
job = "
|
||||
start on hardware-scan
|
||||
stop on shutdown
|
||||
job = ''
|
||||
start on udev
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
export PATH=${modprobe}/sbin:$PATH
|
||||
modprobe af_packet || true
|
||||
start script
|
||||
export PATH=${modprobe}/sbin:$PATH
|
||||
modprobe af_packet || true
|
||||
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
echo \"Bringing up network device $i...\"
|
||||
${nettools}/sbin/ifconfig $i up || true
|
||||
done
|
||||
|
||||
# Configure the manually specified interfaces.
|
||||
names=(${toString names})
|
||||
ipAddresses=(${toString ipAddresses})
|
||||
subnetMasks=(${toString subnetMasks})
|
||||
essids=(${toString essids})
|
||||
wepKeys=(${toString wepKeys})
|
||||
|
||||
for ((n = 0; n < \${#names[*]}; n++)); do
|
||||
name=\${names[$n]}
|
||||
ipAddress=\${ipAddresses[$n]}
|
||||
subnetMask=\${subnetMasks[$n]}
|
||||
essid=\${essids[$n]}
|
||||
wepKey=\${wepKeys[$n]}
|
||||
|
||||
# Set wireless networking stuff.
|
||||
if test \"$essid\" != default; then
|
||||
${wirelesstools}/sbin/iwconfig \"$name\" essid \"$essid\" || true
|
||||
fi
|
||||
|
||||
if test \"$wepKey\" != nokey; then
|
||||
${wirelesstools}/sbin/iwconfig \"$name\" key \"$(cat \"$wepKey\")\" || true
|
||||
fi
|
||||
|
||||
# Set IP address / netmask.
|
||||
if test \"$ipAddress\" != dhcp; then
|
||||
echo \"Configuring interface $name...\"
|
||||
extraFlags=
|
||||
if test \"$subnetMask\" != default; then
|
||||
extraFlags=\"$extraFlags netmask $subnetMask\"
|
||||
fi
|
||||
${nettools}/sbin/ifconfig \"$name\" \"$ipAddress\" $extraFlags || true
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Set the nameservers.
|
||||
if test -n \"${toString cfg.nameservers}\"; then
|
||||
rm -f /etc/resolv.conf
|
||||
if test -n \"${cfg.domain}\"; then
|
||||
echo \"domain ${cfg.domain}\" >> /etc/resolv.conf
|
||||
fi
|
||||
for i in ${toString cfg.nameservers}; do
|
||||
echo \"nameserver $i\" >> /etc/resolv.conf
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
echo "Bringing up network device $i..."
|
||||
${nettools}/sbin/ifconfig $i up || true
|
||||
done
|
||||
fi
|
||||
|
||||
# Set the default gateway.
|
||||
if test -n \"${cfg.defaultGateway}\"; then
|
||||
${nettools}/sbin/route add default gw \"${cfg.defaultGateway}\" || true
|
||||
fi
|
||||
# Configure the manually specified interfaces.
|
||||
names=(${toString names})
|
||||
ipAddresses=(${toString ipAddresses})
|
||||
subnetMasks=(${toString subnetMasks})
|
||||
essids=(${toString essids})
|
||||
wepKeys=(${toString wepKeys})
|
||||
|
||||
# Run any user-specified commands.
|
||||
${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true
|
||||
for ((n = 0; n < ''${#names[*]}; n++)); do
|
||||
name=''${names[$n]}
|
||||
ipAddress=''${ipAddresses[$n]}
|
||||
subnetMask=''${subnetMasks[$n]}
|
||||
essid=''${essids[$n]}
|
||||
wepKey=''${wepKeys[$n]}
|
||||
|
||||
end script
|
||||
# Set wireless networking stuff.
|
||||
if test "$essid" != default; then
|
||||
${wirelesstools}/sbin/iwconfig "$name" essid "$essid" || true
|
||||
fi
|
||||
|
||||
# Hack: Upstart doesn't yet support what we want: a service that
|
||||
# doesn't have a running process associated with it.
|
||||
respawn sleep 100000
|
||||
if test "$wepKey" != nokey; then
|
||||
${wirelesstools}/sbin/iwconfig "$name" key "$(cat "$wepKey")" || true
|
||||
fi
|
||||
|
||||
stop script
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
echo \"Taking down network device $i...\"
|
||||
${nettools}/sbin/ifconfig $i down || true
|
||||
done
|
||||
end script
|
||||
# Set IP address / netmask.
|
||||
if test "$ipAddress" != dhcp; then
|
||||
echo "Configuring interface $name..."
|
||||
extraFlags=
|
||||
if test "$subnetMask" != default; then
|
||||
extraFlags="$extraFlags netmask $subnetMask"
|
||||
fi
|
||||
${nettools}/sbin/ifconfig "$name" "$ipAddress" $extraFlags || true
|
||||
fi
|
||||
|
||||
";
|
||||
done
|
||||
|
||||
# Set the nameservers.
|
||||
if test -n "${toString cfg.nameservers}"; then
|
||||
rm -f /etc/resolv.conf
|
||||
if test -n "${cfg.domain}"; then
|
||||
echo "domain ${cfg.domain}" >> /etc/resolv.conf
|
||||
fi
|
||||
for i in ${toString cfg.nameservers}; do
|
||||
echo "nameserver $i" >> /etc/resolv.conf
|
||||
done
|
||||
fi
|
||||
|
||||
# Set the default gateway.
|
||||
if test -n "${cfg.defaultGateway}"; then
|
||||
${nettools}/sbin/route add default gw "${cfg.defaultGateway}" || true
|
||||
fi
|
||||
|
||||
# Run any user-specified commands.
|
||||
${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true
|
||||
|
||||
end script
|
||||
|
||||
# Hack: Upstart doesn't yet support what we want: a service that
|
||||
# doesn't have a running process associated with it.
|
||||
respawn sleep 100000
|
||||
|
||||
stop script
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
echo "Taking down network device $i..."
|
||||
${nettools}/sbin/ifconfig $i down || true
|
||||
done
|
||||
end script
|
||||
'';
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ rec {
|
||||
];
|
||||
|
||||
job = ''
|
||||
start on hardware-scan
|
||||
start on udev
|
||||
|
||||
start script
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ stdenv, writeText, substituteAll, cleanSource, udev, procps, firmwareDirs
|
||||
{ stdenv, writeText, substituteAll, cleanSource, udev, procps, firmwareDirs, modprobe
|
||||
, extraUdevPkgs ? []
|
||||
, sndMode ? "0600"
|
||||
}:
|
||||
@ -44,9 +44,9 @@ let
|
||||
ensureDir $out
|
||||
ln -s ${nixRules} $out/${nixRules.name}
|
||||
shopt -s nullglob
|
||||
cp ${udev}/etc/udev/rules.d/50-udev-default.rules $out/
|
||||
cp ${udev}/etc/udev/rules.d/60-persistent-storage.rules $out/
|
||||
cp ${udev}/etc/udev/rules.d/95-udev-late.rules $out/
|
||||
cp ${udev}/etc/udev/rules.d/*.rules $out/
|
||||
substituteInPlace $out/80-drivers.rules \
|
||||
--replace /sbin/modprobe ${modprobe}/sbin/modprobe
|
||||
for i in ${toString extraUdevPkgs}; do
|
||||
for j in $i/etc/udev/rules.d/*; do
|
||||
ln -s $j $out/$(basename $j)
|
||||
|
Loading…
Reference in New Issue
Block a user