Closed Silverdev2482 closed 1 year ago
Hi, thanks for submitting this issue and for providing your system configuration!
I might have run into this issue before when switching from fprintd to open-fprintd.
In that case, I think running systemctl restart open-fprintd
and systemctl restart python-validity
after nixos-rebuild
resolved it, for some reason.
If you have not been running fprintd
before switching to this configuration, its probably something else.
I am a bit busy at the moment, but I'll take a look at this within the next week.
Also, please remove inputs.nixpkgs.follows = "nixpkgs";
from the nixos-06cb-009a-fingerprint-sensor
flake.
I only tested this flake for NixOS stable / NixOS 22.11 and as I just found out through this issue, this flake unfortunately is currently not compatible with NixOS unstable.
If you remove the inputs.nixpkgs.follows = "nixpkgs";
line, the flake should automatically use the nixpkgs
from NixOS 22.11 for its dependencies.
I'll update the ReadMe regarding this shortly.
That did not fix my issue however I did find something that could be of use:
[silverdev2482@nixos:~/Configuration]$ sudo systemctl status open-fprintd | wl-copy
● open-fprintd.service - Open FPrint Daemon
Loaded: loaded (/etc/systemd/system/open-fprintd.service; linked; preset: enabled)
Active: active (running) since Sat 2023-04-22 11:39:00 CDT; 2min 15s ago
Main PID: 13825 (.open-fprintd-w)
IP: 0B in, 0B out
IO: 0B read, 0B written
Tasks: 1 (limit: 18867)
Memory: 10.3M
CPU: 100ms
CGroup: /system.slice/open-fprintd.service
└─13825 /nix/store/rpri9nb8xpwwqakyrqbg8zdslkjs2hd3-python3-3.10.11/bin/python3.10 /nix/store/d04y7c5v1m1i51xla096448562sqgc3g-python3.10-open-fprintd-0.6/bin/.open-fprintd-wrapped --debug
Apr 22 11:39:00 nixos systemd[1]: Starting Open FPrint Daemon...
Apr 22 11:39:00 nixos systemd[1]: Started Open FPrint Daemon.
Apr 22 11:39:00 nixos open-fprintd[13825]: /nix/store/d04y7c5v1m1i51xla096448562sqgc3g-python3.10-open-fprintd-0.6/bin/.open-fprintd-wrapped:26: PyGIDeprecationWarning: GObject.MainLoop is deprecated; use GLib.MainLoop instead
Apr 22 11:39:00 nixos open-fprintd[13825]: GObject.MainLoop().run()
Apr 22 11:39:12 nixos open-fprintd[13825]: DEBUG:root:GetDefaultDevice
[silverdev2482@nixos:~/Configuration]$ sudo systemctl status python3-validity.service | wl-copy
× python3-validity.service - python-validity driver dbus service
Loaded: loaded (/etc/systemd/system/python3-validity.service; enabled; preset: enabled)
Drop-In: /nix/store/r45v0lyv7k7yg1insa1xf6jyy06y9ndy-system-units/python3-validity.service.d
└─overrides.conf
Active: failed (Result: exit-code) since Sat 2023-04-22 11:39:08 CDT; 1min 12s ago
Duration: 694ms
Process: 13844 ExecStart=/nix/store/izphf8rk8r8gdpcc2c3pj44j68k9i6pn-python3.10-python-validity-0.14/bin/python-validity-dbus-service --debug (code=exited, status=1/FAILURE)
Main PID: 13844 (code=exited, status=1/FAILURE)
IP: 0B in, 0B out
CPU: 252ms
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: init.open()
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: File "/nix/store/izphf8rk8r8gdpcc2c3pj44j68k9i6pn-python3.10-python-validity-0.14/lib/python3.10/site-packages/validitysensor/init.py", line 48, in open
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: open_common()
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: File "/nix/store/izphf8rk8r8gdpcc2c3pj44j68k9i6pn-python3.10-python-validity-0.14/lib/python3.10/site-packages/validitysensor/init.py", line 33, in open_common
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: upload_fwext()
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: File "/nix/store/izphf8rk8r8gdpcc2c3pj44j68k9i6pn-python3.10-python-validity-0.14/lib/python3.10/site-packages/validitysensor/upload_fwext.py", line 48, in upload_fwext
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: with open(fw_path, 'rb') as f:
Apr 22 11:39:08 nixos python-validity-dbus-service[13844]: FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/izphf8rk8r8gdpcc2c3pj44j68k9i6pn-python3.10-python-validity-0.14/share/python-validity/6_07f_lenovo_mis_qm.xpfwext'
Apr 22 11:39:08 nixos systemd[1]: python3-validity.service: Main process exited, code=exited, status=1/FAILURE
Apr 22 11:39:08 nixos systemd[1]: python3-validity.service: Failed with result 'exit-code'.
Oh yeah just to confirm I did remove the line and I'm pretty sure it at least backdated the packages to the correct versions, restarting the services seemingly has no affect.
/nix/store/izphf8rk8r8gdpcc2c3pj44j68k9i6pn-python3.10-python-validity-0.14/share/python-validity/6_07f_lenovo_mis_qm.xpfwext so this file not existing appears to be a problem, the directory is there just up to the file which isn't there.
I have discovered by trying to execute random script these errors come from a python script called validity-sensor-firmware.
Now I realize that I get this same output from the python-validity-dbus-service script.
I'm not sure if this is useful, you probably already know this but my findings could be useful
Any ideas for what is wrong?
I did take a rough look again at the python-validity source code, and it looks like the download_and_extract_fw()
in bin/validity-sensors-firmware
method might not have executed properly for some reason.
I suspect this part of the code is responsible for loading the 6_07f_lenovo_mis_qm.xpfwext
file that is missing in the error log you shared.
As to when it is executed, and why it might have failed, I need to check.
Sorry for not replying earlier this week, I've been very busy unfortunately. I will try to take a look later today into why download_and_extract_fw()
might fail.
EDIT
I have discovered by trying to execute random script these errors come from a python script called validity-sensor-firmware.
Ah I see you have also found it
Ok, I think I now understand what is happening, and why I never ran into this issue.
The firmware downloaded by download_and_extract_fw()
is only ever needed, if it has not yet been flashed to the sensor device.
The method upload_fwext()
, which is always called as part of python-validity's startup procedure checks whether the necessary firmware has already been flashed in lines 24 and 25.
If it has already been flashed, the failing code requiring the firmware at line 48 is never executed.
Now, the firmware has already been flashed on my fp sensor, probably before I even started work on this repository, likely when I was still using python-validity on Arch Linux before the switch to Nix. So I never ran into this problem during testing.
The next part of this problem is that the firmware is not downloaded as part of the installation process, i.e. bin/validity-sensors-firmware
is not properly executed.
So as the next step, I either need to adapt the build process to download the firmware, or patch upload_fwext
so that it is done on the fly when required.
I will do so soon-ish, not sure if I can today. Sorry for the delays.
I think I might have a fix ready now. This should be perfectly safe, since the fix just involves calling existing firmware download and installation scripts in python-validity, but let me reiterate that I do not take any responsibility for any issues caused by the use of this flake.
If you want, you can try out the fix like this:
Please switch to the branch fix-missing-firmware
, i.e. change the flake url like this:
url = "github:ahbnr/nixos-06cb-009a-fingerprint-sensor/fix-missing-firmware";
Then do a nix flake update
, commit the changes and try a nixos-rebuild
.
After that try downloading the firmware like this (run as root):
systemctl stop python3-validity
validity-sensors-firmware
systemctl start python3-validity
Then you can continue in the Readme where you last stopped.
Some background info on what I changed:
python-validity contains functionality to recognize the available fp sensor hardware, download the correct firmware, and upload it to the sensor.
Hardware recognition and download is implemented by the bin/validity-sensors-firmware script and it is actually meant to be executed during package installation on distributions like debian.
However, the hardware recognition does not seem to work in a Nix build environment (likely due to unavailable permissions/capabilities). Furthermore, it is probably not good to introduce these sort of side-effects when building a package.
There are two ways to resolve this:
The package needs to accept the fp sensor id as a parameter and downloads the firmware during the build process. The hardware detection of python-validity is not executed.
The firmware download is not part of the package build process. Instead, the user has to run bin/validity-sensors-firmware manually, the first time they use the software.
I opted for the second option, since the first option is prone to user error. Also, it makes the flake harder to maintain because if the firmware recognition and download code changes in python-validity, we have to update the package input options, too.
Having to call validiy-sensors-firmware
manually is a bit tedious. Maybe I can further improve the flake by patching the python-validity service so that it auto-downloads the firmware.
fprintd-enroll did work so I think its working. You should add validity-sensors-firmware too the path though if you choose to do the second option. also add that to the readme.
fprintd-enroll did work so I think its working.
Good to hear! Once you have enrolled your fingerprints I would also recommend to you to switch to the second driver option mentioned in the Readme, i.e. the libfprint-tod-vfs0090 driver fork by bingch. It works much more reliably for me than open-fprintd+python-validity. Also, open-fprintd is lacking authentication mechanisms for fingerprint enrolling, which is a bit concerning regarding security.
You should add validity-sensors-firmware too the path though
Hmm.. I actually did adapt the module so that validity-sensors-firmware
automatically is on the path when you set
services.python-validity.enable = true;
It seems to work on my system, does it not automatically appear on your path?
add that to the readme
Of course. If everything is working for you now, I'll add some information about calling validity-sensors-firmware
to the Readme and then close the issue after that.
fprintd-enroll and fprintd-verify do work but I can't get authentication done now. When I try to do step 4 I get this error:
[silverdev2482@nixos:~/Configuration]$ ./update.sh
error: undefined variable 'nixos-06cb-009a-fingerprint-sensor'
at /nix/store/knkwq0qbmk0l5ch897v1piskcpyg1898-source/configuration.nix:116:21:
115| auth sufficient pam_unix.so likeauth try_first_pass nullok
116| auth sufficient ${nixos-06cb-009a-fingerprint-sensor.localPackages.fprintd-clients}/lib/security/pam_fprintd.so
| ^
117| auth required pam_deny.so
(use '--show-trace' to show detailed location information)
when I go to the bingch driver i get this error:
[silverdev2482@nixos:~/Configuration]$ ./update.sh
[sudo] password for silverdev2482:
error: undefined variable 'nixos-06cb-009a-fingerprint-sensor'
at /nix/store/nvqx3i0asaxvxf7w9qwy3qjdcjkm4di1-source/configuration.nix:129:14:
128| enable = true;
129| driver = nixos-06cb-009a-fingerprint-sensor.lib.libfprint-2-tod1-vfs0090-bingch {
| ^
130| calib-data-file = ./calib-data.bin;
(use '--show-trace' to show detailed location information)
Is there a problem with my flake?
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
hyprland.url = "github:hyprwm/Hyprland";
stardustxr.url = "github:StardustXR/server";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-06cb-009a-fingerprint-sensor.url = "github:ahbnr/nixos-06cb-009a-fingerprint-sensor";
};
outputs = {
self,
nixpkgs,
home-manager,
hyprland,
nixos-06cb-009a-fingerprint-sensor,
...
}: let
system = "x86_64-linux";
in {
nixosConfigurations = {
silverdev2482 = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./hardware-configuration.nix
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.silverdev2482 = {
imports = [./home.nix];
};
}
hyprland.nixosModules.default
{programs = {
hyprland.enable = true;
};
}
# nixos-06cb-009a-fingerprint-sensor.nixosModules.open-fprintd
# nixos-06cb-009a-fingerprint-sensor.nixosModules.python-validity
];
};
};
};
}
Can you try out the following changes:
Pass on the flake inputs to your external configuration via specialArgs
.
I.e. change the following lines
outputs = {
self,
nixpkgs,
home-manager,
hyprland,
nixos-06cb-009a-fingerprint-sensor,
...
}
to
outputs = {
self,
nixpkgs,
home-manager,
hyprland,
nixos-06cb-009a-fingerprint-sensor,
...
}@attrs
that is, capture the inputs in a attrs
variable.
Then add specialArgs = attrs;
to your nixosSystem
call.
I.e. it should look like this:
silverdev2482 = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = attrs;
modules = [
...
];
};
Declare nixos-06cb-009a-fingerprint-sensor
as an argument of your configuration file, that is, in your configuration.nix
change the line
{ config, pkgs, lib, ... }:
to
{ config, pkgs, lib, nixos-06cb-009a-fingerprint-sensor, ... }:
Then the variable nixos-06cb-009a-fingerprint-sensor
should become available in your configuration.
This is also probably something that I should make clear in the README.
Your advice works, I have the bingch driver working now. For some reason it wasn't immediately working after reboot. however messing with restarting systemd stuff seemed to fix it. I'm not sure why this happened but it working now. Maybe I just made a false observation. If you don't mind I actually feel like hunting down t480 owners with NixOS.
If you don't mind I actually feel like hunting down t480 owners with NixOS.
I'm not sure if I understand, you mean you want to find more T480 users for testing the sensor on NixOS?
Yeah, just by searching t480 on NixOS forms.
Sounds like a good idea. Through this single issue you already helped me uncovered multiple problems with the flake / readme. Having more people test the flake might be helpful.
Btw. do you consider this issue completed? Then I would close it
Yes
Ah, btw. I already merged the fix-missing-firmware
branch with main
. So if you want, you can adjust your flake.nix and switch back to the main branch.
I have followed the first part of the instructions up to step 3. However i get the error: list_devices failed: I am on a thinkpad t480. I see this similar issue: https://github.com/uunicorn/open-fprintd/issues/6 I have the inputs modules and services enabled for open-fprintd and python-validity. I don't have the services or packages for fprintd installed or enabled. Here are my config files, sorry for messed up formatting
flake.nix