Created
April 26, 2025 17:59
-
-
Save MrQubo/b27c4f52afd6d727d523aa95c0b71580 to your computer and use it in GitHub Desktop.
synaTudor on NixOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| pkgs, | |
| ... | |
| }: | |
| { | |
| environment.systemPackages = [ pkgs.libfprint-2-tod1-synatudor ]; | |
| services.dbus.packages = [ pkgs.libfprint-2-tod1-synatudor ]; | |
| systemd.packages = [ pkgs.libfprint-2-tod1-synatudor ]; | |
| # By default fprintd is activated on the first use. | |
| # But libfprint-2-tod1-synatudor takes a long time to startup which causes big delays on first authentication attempt. | |
| # Startup fprintd on boot instead. | |
| systemd.units."fprintd.service".wantedBy = [ "multi-user.target" ]; | |
| services.fprintd = { | |
| enable = true; | |
| tod.enable = true; | |
| tod.driver = pkgs.libfprint-2-tod1-synatudor; | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final: prev: { | |
| libfprint-tod = prev.libfprint-tod.overrideAttrs (prevAttrs: rec { | |
| version = "1.94.6+tod1"; | |
| src = final.fetchFromGitLab { | |
| domain = "gitlab.freedesktop.org"; | |
| owner = "3v1n0"; | |
| repo = "libfprint"; | |
| rev = "v${version}"; | |
| hash = "sha256-Ce56BIkuo2MnDFncNwq022fbsfGtL5mitt+gAAPcO/Y="; | |
| }; | |
| mesonFlags = prevAttrs.mesonFlags ++ [ | |
| "-Dudev_rules_dir=${placeholder "out"}/lib/udev/rules.d" | |
| ]; | |
| nativeBuildInputs = prevAttrs.nativeBuildInputs; | |
| postPatch = '' | |
| ${prevAttrs.postPatch} | |
| patchShebangs ./libfprint/tod/tests/*.sh | |
| ''; | |
| }); | |
| fprintd-tod = prev.fprintd-tod.overrideAttrs rec { | |
| version = "1.94.3"; | |
| src = final.fetchFromGitLab { | |
| domain = "gitlab.freedesktop.org"; | |
| owner = "libfprint"; | |
| repo = "fprintd"; | |
| rev = "v${version}"; | |
| hash = "sha256-shH+ctQAx4fpTMWTmo3wB45ZS38Jf8RknryPabfZ6QE="; | |
| }; | |
| patches = null; | |
| postPatch = prev.fprintd.postPatch; | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| stdenv, | |
| lib, | |
| fetchurl, | |
| fetchFromGitHub, | |
| pkg-config, | |
| meson, | |
| ninja, | |
| openssl, | |
| libusb1, | |
| libcap, | |
| libseccomp, | |
| glib, | |
| dbus, | |
| libfprint-tod, | |
| gusb, | |
| innoextract, | |
| gccForLibs, | |
| withCli ? false, # cli is for debug usage only | |
| }: | |
| let | |
| rev = "d8d9b6dbd8163efd207b706672b740c277f25fb7"; | |
| installer = fetchurl { | |
| url = "https://download.lenovo.com/pccbbs/mobiles/r19fp02w.exe"; | |
| hash = "sha256-CfBurJRksBhsGxyN7Xlppik3Lh14nPxsi9d3xydbaY8="; | |
| }; | |
| in | |
| stdenv.mkDerivation { | |
| name = "libfprint-2-tod1-synatudor"; | |
| # TODO: PR some changes to upstream and use patches for the rest. | |
| src = fetchFromGitHub { | |
| inherit rev; | |
| owner = "MrQubo"; | |
| repo = "synaTudor"; | |
| hash = "sha256-RP1ObwvCHGBb2Bt/cbFeTZ8PM3Que2a5FJ59tSGmW+s="; | |
| }; | |
| preConfigure = | |
| '' | |
| # INSTALL_DIR has a hardcoded reference to /sbin | |
| substituteInPlace meson.build \ | |
| --replace-fail '/sbin' '${placeholder "out"}/bin' | |
| substituteInPlace libtudor/download_driver.sh \ | |
| --replace-fail 'wget https://download.lenovo.com/pccbbs/mobiles/r19fp02w.exe -O "$INSTALLER"'$'\n' 'cp ${installer} "$INSTALLER"'$'\n' | |
| # We already checked the hash. No need to add perl as dependency. | |
| sed -i '/shasum "$INSTALLER"/d' libtudor/download_driver.sh | |
| '' | |
| + lib.optionalString (!withCli) '' | |
| rm -r cli/ | |
| sed -i '/cli/d' meson.build | |
| ''; | |
| doCheck = true; | |
| enableParallelBuilding = false; # TODO: Change to true. | |
| nativeBuildInputs = [ | |
| pkg-config | |
| meson | |
| ninja | |
| innoextract | |
| ]; | |
| buildInputs = [ | |
| openssl | |
| libusb1 | |
| libcap | |
| libseccomp | |
| glib | |
| dbus | |
| libfprint-tod | |
| gusb | |
| gccForLibs.libgcc | |
| ]; | |
| dontUseCmakeConfigure = true; | |
| env.NIX_CFLAGS_COMPILE = "-I${glib.dev}/include/gio-unix-2.0 -I${libfprint-tod}/include/libfprint-2"; | |
| installPhase = | |
| '' | |
| runHook preInstall | |
| install -D tudor-host-launcher/tudor_host_launcher -t $out/bin/tudor | |
| install -D tudor-host/tudor_host -t $out/bin/tudor | |
| install -D libtudor/libtudor.so -t $out/lib | |
| install -D libfprint-tod/libtudor_tod.so -t $out/lib/libfprint-2/tod-1 | |
| install -D tudor-host-launcher/tudor-host-launcher.service -t $out/lib/systemd/system | |
| install -D $src/libfprint-tod/60-tudor-libfprint-tod.rules -t $out/lib/udev/rules.d | |
| install -D tudor-host-launcher/net.reactivated.TudorHostLauncher.service -t $out/share/dbus-1/system-services | |
| install -D $src/tudor-host-launcher/net.reactivated.TudorHostLauncher.conf -t $out/share/dbus-1/system.d | |
| '' | |
| + lib.optionalString withCli '' | |
| install -D cli/tudor_cli -t $out/bin | |
| '' | |
| + '' | |
| runHook postInstall | |
| ''; | |
| passthru.driverPath = "/lib/libfprint-2/tod-1"; | |
| meta = { | |
| } // lib.optionalAttrs withCli { mainProgram = "tudor_cli"; }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment