mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 15:11:35 +00:00
Merge pull request #12724 from abbradar/udev-hwdb
udev service: generate hwdb database from all udev packages
This commit is contained in:
commit
20b54bd989
|
@ -16,6 +16,12 @@ let
|
|||
destination = "/etc/udev/rules.d/10-local.rules";
|
||||
};
|
||||
|
||||
extraHwdbFile = pkgs.writeTextFile {
|
||||
name = "extra-hwdb-file";
|
||||
text = cfg.extraHwdb;
|
||||
destination = "/etc/udev/hwdb.d/10-local.hwdb";
|
||||
};
|
||||
|
||||
nixosRules = ''
|
||||
# Miscellaneous devices.
|
||||
KERNEL=="kvm", MODE="0666"
|
||||
|
@ -104,6 +110,27 @@ let
|
|||
''; # */
|
||||
};
|
||||
|
||||
hwdbBin = stdenv.mkDerivation {
|
||||
name = "hwdb.bin";
|
||||
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p etc/udev/hwdb.d
|
||||
for i in ${toString ([udev] ++ cfg.packages)}; do
|
||||
echo "Adding hwdb files for package $i"
|
||||
for j in $i/{etc,lib}/udev/hwdb.d/*; do
|
||||
ln -s $j etc/udev/hwdb.d/$(basename $j)
|
||||
done
|
||||
done
|
||||
|
||||
echo "Generating hwdb database..."
|
||||
${udev}/bin/udevadm hwdb --update --root=$(pwd)
|
||||
mv etc/udev/hwdb.bin $out
|
||||
'';
|
||||
};
|
||||
|
||||
# Udev has a 512-character limit for ENV{PATH}, so create a symlink
|
||||
# tree to work around this.
|
||||
udevPath = pkgs.buildEnv {
|
||||
|
@ -168,6 +195,21 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
extraHwdb = mkOption {
|
||||
default = "";
|
||||
example = ''
|
||||
evdev:input:b0003v05AFp8277*
|
||||
KEYBOARD_KEY_70039=leftalt
|
||||
KEYBOARD_KEY_700e2=leftctrl
|
||||
'';
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Additional <command>hwdb</command> files. They'll be written
|
||||
into file <filename>10-local.hwdb</filename>. Thus they are
|
||||
read before all other files.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
hardware.firmware = mkOption {
|
||||
|
@ -216,7 +258,7 @@ in
|
|||
|
||||
services.udev.extraRules = nixosRules;
|
||||
|
||||
services.udev.packages = [ extraUdevRules ];
|
||||
services.udev.packages = [ extraUdevRules extraHwdbFile ];
|
||||
|
||||
services.udev.path = [ pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.utillinux udev ];
|
||||
|
||||
|
@ -224,6 +266,9 @@ in
|
|||
[ { source = udevRules;
|
||||
target = "udev/rules.d";
|
||||
}
|
||||
{ source = hwdbBin;
|
||||
target = "udev/hwdb.bin";
|
||||
}
|
||||
];
|
||||
|
||||
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||
|
@ -241,13 +286,6 @@ in
|
|||
echo "" > /proc/sys/kernel/hotplug
|
||||
fi
|
||||
|
||||
# Regenerate the hardware database /var/lib/udev/hwdb.bin
|
||||
# whenever systemd changes.
|
||||
if [ ! -e /var/lib/udev/prev-systemd -o "$(readlink /var/lib/udev/prev-systemd)" != ${config.systemd.package} ]; then
|
||||
echo "regenerating udev hardware database..."
|
||||
${config.systemd.package}/bin/udevadm hwdb --update && ln -sfn ${config.systemd.package} /var/lib/udev/prev-systemd
|
||||
fi
|
||||
|
||||
# Allow the kernel to find our firmware.
|
||||
if [ -e /sys/module/firmware_class/parameters/path ]; then
|
||||
echo -n "${config.hardware.firmware}/lib/firmware" > /sys/module/firmware_class/parameters/path
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
assert stdenv.isLinux;
|
||||
|
||||
# FIXME: When updating, please remove makeFlags -- `hwdb_bin` flag is not supported anymore.
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "228";
|
||||
name = "systemd-${version}";
|
||||
|
|
Loading…
Reference in a new issue