Files
nixpkgs/nixos/modules/hardware/facter/fingerprint/update.nix
Jörg Thalheim 8b9171eed7 nixos/facter: add input peripheral detection
This adds automatic detection and configuration for input peripherals:

- bluetooth: Detects Bluetooth hardware and automatically enables
- fingerprint: Detects USB fingerprint devices using libfprint device database

Builds on PR #458177 (graphics).
Part of incremental upstreaming from nixos-facter-modules.
2025-12-01 13:48:46 +01:00

38 lines
1.1 KiB
Nix

# Run: $(nix-build nixos/modules/hardware/facter/fingerprint/update.nix)/bin/update-fprint-devices
{
pkgs ? import ../../../../.. { },
}:
let
fprint-supported-devices = pkgs.libfprint.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
pkgs.jq
pkgs.gawk
];
buildPhase = ''
ninja libfprint/fprint-list-supported-devices
'';
outputs = [ "out" ];
installPhase = ''
./libfprint/fprint-list-supported-devices | \
grep -o -E '(\b[0-9a-fA-F]{4}:[0-9a-fA-F]{4}\b)' | \
awk '{print toupper($0)}' | \
jq -S -R -s 'split("\n") | map(select(. != "")) | map({key: ., value: true}) | from_entries' > $out
'';
# we cannot disable doInstallcheck because than we are missing nativeCheckInputs dependencies
installCheckPhase = "";
});
in
pkgs.writeShellApplication {
name = "update-fprint-devices";
runtimeInputs = with pkgs; [
coreutils
git
];
text = ''
root="$(git rev-parse --show-toplevel)"
target="$root/nixos/modules/hardware/facter/fingerprint/devices.json"
cp ${fprint-supported-devices} "$target"
echo "Updated $target"
'';
}