Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fingerprint sensors #58

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,37 @@
(pkgs.callPackage ./formatter.nix { inputs = publicInputs // privateInputs; }).config.build.wrapper
);

packages = eachSystem (
{ pkgs, ... }:
{
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 -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 = "";
});
update-fprint-devices = pkgs.writeScriptBin "update-fprint-devices" ''
#!${pkgs.stdenv.shell}
target=$(git rev-parse --show-toplevel)/modules/nixos/fingerprint/devices.json
cat ${publicInputs.self.packages.${pkgs.system}.fprint-supported-devices} > "$target"
nix fmt -- "$target"
git add -- "$target"
'';
}
);

checks = eachSystem (
{ pkgs, ... }:
{
Expand Down
3 changes: 2 additions & 1 deletion modules/nixos/facter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
imports = [
./bluetooth.nix
./disk.nix
./keyboard.nix
./fingerprint
./firmware.nix
./graphics
./keyboard.nix
./networking
./system.nix
./virtualisation.nix
Expand Down
47 changes: 47 additions & 0 deletions modules/nixos/fingerprint/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ lib, config, ... }:
let
devices = builtins.fromJSON (builtins.readFile ./devices.json);
default = {
value = 0;
};

toZeroPaddedHex =
n:
let
hex = lib.toHexString n;
len = builtins.stringLength hex;
in
if len == 1 then
"000${hex}"
else if len == 2 then
"00${hex}"
else if len == 3 then
"0${hex}"
else
hex;

isSupported = lib.any (
{
vendor ? default,
device ? default,
bus_type ? {
name = "";
},
...
}:
bus_type.name == "USB"
&& devices ? "${toZeroPaddedHex vendor.value}:${toZeroPaddedHex device.value}"
);
in
{
options.facter.detected.fingerprint.enable = lib.mkEnableOption "Fingerprint devices" // {
default =
isSupported (config.facter.report.hardware.unknown or [ ])
|| isSupported (config.facter.report.hardware.fingerprint or [ ])
|| isSupported (config.facter.report.hardware.usb or [ ]);
};

config.services.fprintd.enable = lib.mkIf config.facter.detected.fingerprint.enable (
lib.mkDefault true
);
}
194 changes: 194 additions & 0 deletions modules/nixos/fingerprint/devices.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
{
"045E:00BB": true,
Mic92 marked this conversation as resolved.
Show resolved Hide resolved
"045E:00BC": true,
"045E:00BD": true,
"045E:00CA": true,
"0483:2015": true,
"0483:2016": true,
"0483:2017": true,
"04F3:0903": true,
"04F3:0907": true,
"04F3:0C01": true,
"04F3:0C02": true,
"04F3:0C03": true,
"04F3:0C04": true,
"04F3:0C05": true,
"04F3:0C06": true,
"04F3:0C07": true,
"04F3:0C08": true,
"04F3:0C09": true,
"04F3:0C0A": true,
"04F3:0C0B": true,
"04F3:0C0C": true,
"04F3:0C0D": true,
"04F3:0C0E": true,
"04F3:0C0F": true,
"04F3:0C10": true,
"04F3:0C11": true,
"04F3:0C12": true,
"04F3:0C13": true,
"04F3:0C14": true,
"04F3:0C15": true,
"04F3:0C16": true,
"04F3:0C17": true,
"04F3:0C18": true,
"04F3:0C19": true,
"04F3:0C1A": true,
"04F3:0C1B": true,
"04F3:0C1C": true,
"04F3:0C1D": true,
"04F3:0C1E": true,
"04F3:0C1F": true,
"04F3:0C20": true,
"04F3:0C21": true,
"04F3:0C22": true,
"04F3:0C23": true,
"04F3:0C24": true,
"04F3:0C25": true,
"04F3:0C26": true,
"04F3:0C27": true,
"04F3:0C28": true,
"04F3:0C29": true,
"04F3:0C2A": true,
"04F3:0C2B": true,
"04F3:0C2C": true,
"04F3:0C2D": true,
"04F3:0C2E": true,
"04F3:0C2F": true,
"04F3:0C30": true,
"04F3:0C31": true,
"04F3:0C32": true,
"04F3:0C33": true,
"04F3:0C3D": true,
"04F3:0C42": true,
"04F3:0C4B": true,
"04F3:0C4D": true,
"04F3:0C4F": true,
"04F3:0C58": true,
"04F3:0C63": true,
"04F3:0C6E": true,
"04F3:0C7D": true,
"04F3:0C7E": true,
"04F3:0C82": true,
"04F3:0C88": true,
"04F3:0C8C": true,
"04F3:0C8D": true,
"04F3:0C99": true,
"05BA:0007": true,
"05BA:0008": true,
"05BA:000A": true,
"061A:0110": true,
"06CB:00BD": true,
"06CB:00C2": true,
"06CB:00DF": true,
"06CB:00F0": true,
"06CB:00F9": true,
"06CB:00FC": true,
"06CB:0100": true,
"06CB:0103": true,
"06CB:0104": true,
"06CB:0123": true,
"06CB:0126": true,
"06CB:0129": true,
"06CB:015F": true,
"06CB:0168": true,
"08FF:1600": true,
"08FF:1660": true,
"08FF:1680": true,
"08FF:1681": true,
"08FF:1682": true,
"08FF:1683": true,
"08FF:1684": true,
"08FF:1685": true,
"08FF:1686": true,
"08FF:1687": true,
"08FF:1688": true,
"08FF:1689": true,
"08FF:168A": true,
"08FF:168B": true,
"08FF:168C": true,
"08FF:168D": true,
"08FF:168E": true,
"08FF:168F": true,
"08FF:2500": true,
"08FF:2550": true,
"08FF:2580": true,
"08FF:2660": true,
"08FF:2680": true,
"08FF:2681": true,
"08FF:2682": true,
"08FF:2683": true,
"08FF:2684": true,
"08FF:2685": true,
"08FF:2686": true,
"08FF:2687": true,
"08FF:2688": true,
"08FF:2689": true,
"08FF:268A": true,
"08FF:268B": true,
"08FF:268C": true,
"08FF:268D": true,
"08FF:268E": true,
"08FF:268F": true,
"08FF:2691": true,
"08FF:2810": true,
"08FF:5501": true,
"08FF:5731": true,
"10A5:A305": true,
"10A5:D205": true,
"10A5:D805": true,
"10A5:DA04": true,
"10A5:FFE0": true,
"138A:0001": true,
"138A:0005": true,
"138A:0008": true,
"138A:0010": true,
"138A:0011": true,
"138A:0015": true,
"138A:0017": true,
"138A:0018": true,
"138A:0050": true,
"138A:0091": true,
"147E:1000": true,
"147E:1001": true,
"147E:2016": true,
"147E:2020": true,
"147E:3001": true,
"1C7A:0570": true,
"1C7A:0571": true,
"1C7A:0603": true,
"27C6:5840": true,
"27C6:6014": true,
"27C6:6092": true,
"27C6:6094": true,
"27C6:609C": true,
"27C6:60A2": true,
"27C6:60A4": true,
"27C6:60BC": true,
"27C6:6304": true,
"27C6:631C": true,
"27C6:633C": true,
"27C6:634C": true,
"27C6:6384": true,
"27C6:639C": true,
"27C6:63AC": true,
"27C6:63BC": true,
"27C6:63CC": true,
"27C6:6496": true,
"27C6:6584": true,
"27C6:658C": true,
"27C6:6592": true,
"27C6:6594": true,
"27C6:659A": true,
"27C6:659C": true,
"27C6:6A94": true,
"298D:1010": true,
"04F3:241F": true,
"04F3:3057": true,
"04F3:3087": true,
"04F3:309F": true,
"04F3:30B2": true,
"04F3:30C6": true,
"04F3:3148": true,
"04F3:3134": true
}