* Udev rules/script to load device firmware automatically. The udev
job takes a list of firmware directories in which to search for firmware files. Right now this is just the Intel 2200 firmware (if enabled). svn path=/nixos/trunk/; revision=8162
This commit is contained in:
parent
1a9f5e455e
commit
2bff886ae1
@ -3,13 +3,6 @@
|
||||
[
|
||||
|
||||
|
||||
{
|
||||
name = ["networking" "hostName"];
|
||||
default = "nixos";
|
||||
description = "The name of the machine.";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["time" "timeZone"];
|
||||
default = "CET";
|
||||
@ -186,6 +179,13 @@
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["networking" "hostName"];
|
||||
default = "nixos";
|
||||
description = "The name of the machine.";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["networking" "useDHCP"];
|
||||
default = true;
|
||||
@ -234,6 +234,19 @@
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["networking" "enableIntel2200BGFirmware"];
|
||||
default = false;
|
||||
description = "
|
||||
Turn on this option if you want firmware for the Intel
|
||||
PRO/Wireless 2200BG to be loaded automatically. This is
|
||||
required if you want to use this device. Intel requires you to
|
||||
accept the license for this firmware, see
|
||||
<link xlink:href='http://ipw2200.sourceforge.net/firmware.php?fid=7'/>.
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["fileSystems"];
|
||||
default = [];
|
||||
|
@ -23,8 +23,10 @@ import ../upstart-jobs/gather.nix {
|
||||
# The udev daemon creates devices nodes and runs programs when
|
||||
# hardware events occur.
|
||||
(import ../upstart-jobs/udev.nix {
|
||||
inherit (pkgs) writeText udev procps;
|
||||
inherit (pkgs) stdenv writeText substituteAll udev procps;
|
||||
inherit (pkgs.lib) cleanSource;
|
||||
firmwareDirs =
|
||||
(if config.get ["networking" "enableIntel2200BGFirmware"] then [pkgs.ipw2200fw] else []);
|
||||
})
|
||||
|
||||
# Makes LVM logical volumes available.
|
||||
|
30
upstart-jobs/udev-firmware-loader.sh
Executable file
30
upstart-jobs/udev-firmware-loader.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#! @shell@
|
||||
|
||||
export PATH="@path@"
|
||||
|
||||
exec > /var/log/udev-fw 2>&1
|
||||
|
||||
if test "$ACTION" = "add"; then
|
||||
|
||||
ls -l /sys/$DEVPATH >> /tmp/fw 2>&1
|
||||
|
||||
if ! test -e /sys/$DEVPATH/loading; then
|
||||
echo "Firmware loading is not supported by device \`DEVPATH'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dir in @firmwareDirs@; do
|
||||
if test -e "$dir/$FIRMWARE"; then
|
||||
echo "Loading \`$FIRMWARE' for device \`$DEVPATH' from $dir."
|
||||
echo 1 > /sys/$DEVPATH/loading
|
||||
cat "$dir/$FIRMWARE" > /sys/$DEVPATH/data
|
||||
echo 0 > /sys/$DEVPATH/loading
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Firmware \`$FIRMWARE' for device \`$DEVPATH' not found."
|
||||
echo -1 > /sys/$DEVPATH/loading
|
||||
exit 1
|
||||
|
||||
fi
|
@ -14,7 +14,7 @@ KERNEL=="kvm", MODE="0666"
|
||||
|
||||
|
||||
# TTYs.
|
||||
KERNEL=="tty", NAME="%k", MODE="666", OPTIONS="last_rule" # GROUP="tty"
|
||||
KERNEL=="tty", NAME="%k", MODE="666", OPTIONS="last_rule" # GROUP="tty"
|
||||
KERNEL=="ptmx", NAME="%k", MODE="666" # GROUP="tty"
|
||||
|
||||
|
||||
@ -37,3 +37,7 @@ KERNEL=="pcmC[D0-9cp]*", NAME="snd/%k"
|
||||
KERNEL=="midiC[D0-9]*", NAME="snd/%k"
|
||||
KERNEL=="timer", NAME="snd/%k"
|
||||
KERNEL=="seq", NAME="snd/%k"
|
||||
|
||||
|
||||
# Firmware loading.
|
||||
SUBSYSTEM=="firmware", ACTION=="add", RUN+="@firmwareLoader@"
|
||||
|
@ -1,9 +1,29 @@
|
||||
{writeText, cleanSource, udev, procps}:
|
||||
{stdenv, writeText, substituteAll, cleanSource, udev, procps, firmwareDirs}:
|
||||
|
||||
let
|
||||
|
||||
# Perform substitutions in all udev rules files.
|
||||
udevRules = stdenv.mkDerivation {
|
||||
name = "udev-rules";
|
||||
src = cleanSource ./udev-rules;
|
||||
firmwareLoader = substituteAll {
|
||||
src = ./udev-firmware-loader.sh;
|
||||
path = "${stdenv.coreutils}/bin";
|
||||
isExecutable = true;
|
||||
inherit firmwareDirs;
|
||||
};
|
||||
buildCommand = "
|
||||
buildCommand= # urgh
|
||||
ensureDir $out
|
||||
for i in $src/*; do
|
||||
substituteAll $i $out/$(basename $i)
|
||||
done
|
||||
";
|
||||
};
|
||||
|
||||
# The udev configuration file
|
||||
conf = writeText "udev.conf" "
|
||||
udev_rules=\"${cleanSource ./udev-rules}\"
|
||||
udev_rules=\"${udevRules}\"
|
||||
";
|
||||
|
||||
in
|
||||
|
Loading…
Reference in New Issue
Block a user