Skip to content

Commit 39c2a1e

Browse files
committed
detect fingerprint sensors
1 parent 14bf524 commit 39c2a1e

File tree

4 files changed

+258
-1
lines changed

4 files changed

+258
-1
lines changed

flake.nix

+31
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,37 @@
6060
(pkgs.callPackage ./formatter.nix { inputs = publicInputs // privateInputs; }).config.build.wrapper
6161
);
6262

63+
packages = eachSystem (
64+
{ pkgs, ... }:
65+
{
66+
fprint-supported-devices = pkgs.libfprint.overrideAttrs (old: {
67+
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
68+
pkgs.jq
69+
pkgs.gawk
70+
];
71+
buildPhase = ''
72+
ninja libfprint/fprint-list-supported-devices
73+
'';
74+
outputs = [ "out" ];
75+
installPhase = ''
76+
./libfprint/fprint-list-supported-devices | \
77+
grep -o -E '(\b[0-9a-fA-F]{4}:[0-9a-fA-F]{4}\b)' | \
78+
awk '{print toupper($0)}' | \
79+
jq -R -s 'split("\n") | map(select(. != "")) | map({key: ., value: true}) | from_entries' > $out
80+
'';
81+
# we cannot disable doInstallcheck because than we are missing nativeCheckInputs dependencies
82+
installCheckPhase = "";
83+
});
84+
update-fprint-devices = pkgs.writeScriptBin "update-fprint-devices" ''
85+
#!${pkgs.stdenv.shell}
86+
target=$(git rev-parse --show-toplevel)/modules/nixos/fingerprint/devices.json
87+
cat ${publicInputs.self.packages.${pkgs.system}.fprint-supported-devices} > "$target"
88+
nix fmt -- "$target"
89+
git add -- "$target"
90+
'';
91+
}
92+
);
93+
6394
checks = eachSystem (
6495
{ pkgs, ... }:
6596
{

modules/nixos/facter.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
imports = [
88
./bluetooth.nix
99
./disk.nix
10-
./keyboard.nix
10+
./fingerprint
1111
./firmware.nix
1212
./graphics
13+
./keyboard.nix
1314
./networking
1415
./system.nix
1516
./virtualisation.nix

modules/nixos/fingerprint/default.nix

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{ lib, config, ... }:
2+
let
3+
devices = builtins.fromJSON (builtins.readFile ./devices.json);
4+
default = {
5+
value = 0;
6+
};
7+
isSupported = lib.any (
8+
{
9+
vendor ? default,
10+
device ? default,
11+
bus_type ? {
12+
name = "";
13+
},
14+
...
15+
}:
16+
bus_type.name == "USB"
17+
&& devices ? "${lib.toHexString vendor.value}:${lib.toHexString device.value}"
18+
);
19+
in
20+
{
21+
options.facter.detected.fingerprint.enable = lib.mkEnableOption "Fingerprint devices" // {
22+
default =
23+
isSupported (config.facter.report.hardware.unknown or [ ])
24+
|| isSupported (config.facter.report.hardware.fingerprint or [ ])
25+
|| isSupported (config.facter.report.hardware.usb or [ ]);
26+
};
27+
28+
config.services.fprintd.enable = lib.mkIf config.facter.detected.fingerprint.enable (
29+
lib.mkDefault true
30+
);
31+
}
+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
{
2+
"045E:00BB": true,
3+
"045E:00BC": true,
4+
"045E:00BD": true,
5+
"045E:00CA": true,
6+
"0483:2015": true,
7+
"0483:2016": true,
8+
"0483:2017": true,
9+
"04F3:0903": true,
10+
"04F3:0907": true,
11+
"04F3:0C01": true,
12+
"04F3:0C02": true,
13+
"04F3:0C03": true,
14+
"04F3:0C04": true,
15+
"04F3:0C05": true,
16+
"04F3:0C06": true,
17+
"04F3:0C07": true,
18+
"04F3:0C08": true,
19+
"04F3:0C09": true,
20+
"04F3:0C0A": true,
21+
"04F3:0C0B": true,
22+
"04F3:0C0C": true,
23+
"04F3:0C0D": true,
24+
"04F3:0C0E": true,
25+
"04F3:0C0F": true,
26+
"04F3:0C10": true,
27+
"04F3:0C11": true,
28+
"04F3:0C12": true,
29+
"04F3:0C13": true,
30+
"04F3:0C14": true,
31+
"04F3:0C15": true,
32+
"04F3:0C16": true,
33+
"04F3:0C17": true,
34+
"04F3:0C18": true,
35+
"04F3:0C19": true,
36+
"04F3:0C1A": true,
37+
"04F3:0C1B": true,
38+
"04F3:0C1C": true,
39+
"04F3:0C1D": true,
40+
"04F3:0C1E": true,
41+
"04F3:0C1F": true,
42+
"04F3:0C20": true,
43+
"04F3:0C21": true,
44+
"04F3:0C22": true,
45+
"04F3:0C23": true,
46+
"04F3:0C24": true,
47+
"04F3:0C25": true,
48+
"04F3:0C26": true,
49+
"04F3:0C27": true,
50+
"04F3:0C28": true,
51+
"04F3:0C29": true,
52+
"04F3:0C2A": true,
53+
"04F3:0C2B": true,
54+
"04F3:0C2C": true,
55+
"04F3:0C2D": true,
56+
"04F3:0C2E": true,
57+
"04F3:0C2F": true,
58+
"04F3:0C30": true,
59+
"04F3:0C31": true,
60+
"04F3:0C32": true,
61+
"04F3:0C33": true,
62+
"04F3:0C3D": true,
63+
"04F3:0C42": true,
64+
"04F3:0C4B": true,
65+
"04F3:0C4D": true,
66+
"04F3:0C4F": true,
67+
"04F3:0C58": true,
68+
"04F3:0C63": true,
69+
"04F3:0C6E": true,
70+
"04F3:0C7D": true,
71+
"04F3:0C7E": true,
72+
"04F3:0C82": true,
73+
"04F3:0C88": true,
74+
"04F3:0C8C": true,
75+
"04F3:0C8D": true,
76+
"04F3:0C99": true,
77+
"05BA:0007": true,
78+
"05BA:0008": true,
79+
"05BA:000A": true,
80+
"061A:0110": true,
81+
"06CB:00BD": true,
82+
"06CB:00C2": true,
83+
"06CB:00DF": true,
84+
"06CB:00F0": true,
85+
"06CB:00F9": true,
86+
"06CB:00FC": true,
87+
"06CB:0100": true,
88+
"06CB:0103": true,
89+
"06CB:0104": true,
90+
"06CB:0123": true,
91+
"06CB:0126": true,
92+
"06CB:0129": true,
93+
"06CB:015F": true,
94+
"06CB:0168": true,
95+
"08FF:1600": true,
96+
"08FF:1660": true,
97+
"08FF:1680": true,
98+
"08FF:1681": true,
99+
"08FF:1682": true,
100+
"08FF:1683": true,
101+
"08FF:1684": true,
102+
"08FF:1685": true,
103+
"08FF:1686": true,
104+
"08FF:1687": true,
105+
"08FF:1688": true,
106+
"08FF:1689": true,
107+
"08FF:168A": true,
108+
"08FF:168B": true,
109+
"08FF:168C": true,
110+
"08FF:168D": true,
111+
"08FF:168E": true,
112+
"08FF:168F": true,
113+
"08FF:2500": true,
114+
"08FF:2550": true,
115+
"08FF:2580": true,
116+
"08FF:2660": true,
117+
"08FF:2680": true,
118+
"08FF:2681": true,
119+
"08FF:2682": true,
120+
"08FF:2683": true,
121+
"08FF:2684": true,
122+
"08FF:2685": true,
123+
"08FF:2686": true,
124+
"08FF:2687": true,
125+
"08FF:2688": true,
126+
"08FF:2689": true,
127+
"08FF:268A": true,
128+
"08FF:268B": true,
129+
"08FF:268C": true,
130+
"08FF:268D": true,
131+
"08FF:268E": true,
132+
"08FF:268F": true,
133+
"08FF:2691": true,
134+
"08FF:2810": true,
135+
"08FF:5501": true,
136+
"08FF:5731": true,
137+
"10A5:A305": true,
138+
"10A5:D205": true,
139+
"10A5:D805": true,
140+
"10A5:DA04": true,
141+
"10A5:FFE0": true,
142+
"138A:0001": true,
143+
"138A:0005": true,
144+
"138A:0008": true,
145+
"138A:0010": true,
146+
"138A:0011": true,
147+
"138A:0015": true,
148+
"138A:0017": true,
149+
"138A:0018": true,
150+
"138A:0050": true,
151+
"138A:0091": true,
152+
"147E:1000": true,
153+
"147E:1001": true,
154+
"147E:2016": true,
155+
"147E:2020": true,
156+
"147E:3001": true,
157+
"1C7A:0570": true,
158+
"1C7A:0571": true,
159+
"1C7A:0603": true,
160+
"27C6:5840": true,
161+
"27C6:6014": true,
162+
"27C6:6092": true,
163+
"27C6:6094": true,
164+
"27C6:609C": true,
165+
"27C6:60A2": true,
166+
"27C6:60A4": true,
167+
"27C6:60BC": true,
168+
"27C6:6304": true,
169+
"27C6:631C": true,
170+
"27C6:633C": true,
171+
"27C6:634C": true,
172+
"27C6:6384": true,
173+
"27C6:639C": true,
174+
"27C6:63AC": true,
175+
"27C6:63BC": true,
176+
"27C6:63CC": true,
177+
"27C6:6496": true,
178+
"27C6:6584": true,
179+
"27C6:658C": true,
180+
"27C6:6592": true,
181+
"27C6:6594": true,
182+
"27C6:659A": true,
183+
"27C6:659C": true,
184+
"27C6:6A94": true,
185+
"298D:1010": true,
186+
"04F3:241F": true,
187+
"04F3:3057": true,
188+
"04F3:3087": true,
189+
"04F3:309F": true,
190+
"04F3:30B2": true,
191+
"04F3:30C6": true,
192+
"04F3:3148": true,
193+
"04F3:3134": true
194+
}

0 commit comments

Comments
 (0)