From 61090d14398a05ec0921f0a85216150740471fe0 Mon Sep 17 00:00:00 2001 From: Franek Date: Sat, 22 Feb 2025 08:59:27 +0100 Subject: [PATCH] simplify fingerprint module --- hosts/hulk/modules.nix | 11 +++---- hosts/hulk/users.nix | 22 ++++++------- modules/fingerprint.nix | 51 +++++++++++++++++++++++++++++ modules/open-fprint-suspend-fix.nix | 31 ------------------ profiles/hulk/packages.nix | 1 - profiles/hulk/programs.nix | 8 +++-- profiles/hulk/theme.nix | 20 +++++------ 7 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 modules/fingerprint.nix delete mode 100644 modules/open-fprint-suspend-fix.nix diff --git a/hosts/hulk/modules.nix b/hosts/hulk/modules.nix index 4aca73e..3f3c047 100644 --- a/hosts/hulk/modules.nix +++ b/hosts/hulk/modules.nix @@ -1,10 +1,9 @@ { inputs, ... }: { - imports = [ - ../../modules/greetd.nix - ../../modules/nvidia-support.nix - ../../modules/open-fprint-suspend-fix.nix - inputs.fingerprint-sensor.nixosModules."06cb-009a-fingerprint-sensor" - ]; + imports = [ + ../../modules/greetd.nix + ../../modules/nvidia-support.nix + ../../modules/fingerprint.nix + ]; } diff --git a/hosts/hulk/users.nix b/hosts/hulk/users.nix index 89ead45..506b4e1 100644 --- a/hosts/hulk/users.nix +++ b/hosts/hulk/users.nix @@ -1,16 +1,16 @@ { pkgs, ... }: let - username = "sadorowo"; - fullname = "Franek"; - preferredShell = pkgs.fish; + username = "sadorowo"; + fullname = "Franek"; + preferredShell = pkgs.fish; in { - users.users.${username} = { - isNormalUser = true; - description = fullname; - home = "/home/${username}"; - extraGroups = [ "wheel" "networkmanager" ]; - shell = preferredShell; - ignoreShellProgramCheck = true; # Will do it later in profile configuration - }; + users.users.${username} = { + isNormalUser = true; + description = fullname; + home = "/home/${username}"; + extraGroups = [ "wheel" "networkmanager" ]; + shell = preferredShell; + ignoreShellProgramCheck = true; # Will do it later in profile configuration + }; } diff --git a/modules/fingerprint.nix b/modules/fingerprint.nix new file mode 100644 index 0000000..a1d5734 --- /dev/null +++ b/modules/fingerprint.nix @@ -0,0 +1,51 @@ +{ config, lib, pkgs, inputs, ... }: + +{ + options.services.fingerprint-fix.enable = lib.mkEnableOption "Enable support for fingerprint for P51S-like ThinkPads."; + options.services.fingerprint-fix.calibDataFile = lib.mkOption { + description = "Path to calibration data file."; + }; + + imports = lib.mkIf config.services.fingerprint-fix.enable [ + inputs.fingerprint-sensor.nixosModules."06cb-009a-fingerprint-sensor" + ]; + + config = lib.mkIf config.services.fingerprint-fix.enable { + # Needed because we're getting TLS error with open-fprintd-resume + systemd.services.validity-restart = let + targets = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" "suspend-then-hibernate.target" ]; + in { + description = "Restart services to fix fingerprint integration"; + wantedBy = targets; + after = targets; + serviceConfig = { + type = "simple"; + ExecStart = "systemctl --no-block restart python3-validity.service open-fprintd.service"; + }; + }; + + services."06cb-009a-fingerprint-sensor" = { + enable = true; + backend = "python-validity"; + calib-data-file = config.services.fingerprint-fix.calibDataFile; + }; + + services.open-fprintd.enable = true; + + security.pam.services.login.fprintAuth = true; + security.pam.services.greetd.fprintAuth = true; + security.pam.services.sudo.fprintAuth = true; + security.pam.services.su.fprintAuth = true; + + services.udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0097", ATTR{power/persist}="1" + ''; + + security.pam.services.hyprlock.text = '' + # PAM configuration file for hyprlock + # the 'login' configuration file (see /etc/pam.d/login) + + auth include login + ''; + }; +} diff --git a/modules/open-fprint-suspend-fix.nix b/modules/open-fprint-suspend-fix.nix deleted file mode 100644 index 62f08d3..0000000 --- a/modules/open-fprint-suspend-fix.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - options.services.fingerprint-fix.enable = lib.mkEnableOption "Enable systemd service to restart fingerprint services after suspend."; - options.services.fingerprint-fix.calibDataFile = lib.mkOption { - description = "Path to calibration data file."; - }; - - config = lib.mkIf config.services.fingerprint-fix.enable { - # Needed because we're getting TLS error with open-fprintd-resume - systemd.services.validity-restart = let - targets = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" "suspend-then-hibernate.target" ]; - in { - description = "Restart services to fix fingerprint integration"; - wantedBy = targets; - after = targets; - serviceConfig = { - type = "oneshot"; - ExecStart = "systemctl restart python3-validity.service"; - }; - }; - - services."06cb-009a-fingerprint-sensor" = { - enable = true; - backend = "python-validity"; - calib-data-file = config.services.fingerprint-fix.calibDataFile; - }; - - services.fprintd.enable = lib.mkForce true; # Fprintd is not working with P51s - }; -} diff --git a/profiles/hulk/packages.nix b/profiles/hulk/packages.nix index 161b732..ae01b3e 100644 --- a/profiles/hulk/packages.nix +++ b/profiles/hulk/packages.nix @@ -56,7 +56,6 @@ in { greetd.greetd greetd.tuigreet playerctl adwaita-icon-theme - darkman android-tools filezilla bitwarden-desktop diff --git a/profiles/hulk/programs.nix b/profiles/hulk/programs.nix index f16c5d6..1b8f242 100644 --- a/profiles/hulk/programs.nix +++ b/profiles/hulk/programs.nix @@ -16,8 +16,9 @@ services.darkman = { enable = true; darkModeScripts = { - gtk-theme = '' - ${pkgs.dconf}/bin/dconf write\ + theme = '' + ${pkgs.pywalfox-native}/bin/pywalfox dark + ${pkgs.dconf}/bin/dconf write\ /org/gnome/desktop/interface/color-scheme "'prefer-dark'" ''; @@ -27,7 +28,8 @@ }; lightModeScripts = { - gtk-theme = '' + theme = '' + ${pkgs.pywalfox-native}/bin/pywalfox light ${pkgs.dconf}/bin/dconf write\ /org/gnome/desktop/interface/color-scheme "'prefer-light'" ''; diff --git a/profiles/hulk/theme.nix b/profiles/hulk/theme.nix index c60ac9a..63cc9bf 100644 --- a/profiles/hulk/theme.nix +++ b/profiles/hulk/theme.nix @@ -1,17 +1,17 @@ { pkgs, inputs, ... }: let - nerdfonts = (pkgs.nerdfonts.override { - fonts = [ - "CascadiaCode" - "JetBrainsMono" - "FiraCode" - "SpaceMono" - ]; - }); + nerdfonts = (pkgs.nerdfonts.override { + fonts = [ + "CascadiaCode" + "JetBrainsMono" + "FiraCode" + "SpaceMono" + ]; + }); - cursor-theme = "Bibata-Modern-Classic"; - cursor-pkg = pkgs.bibata-cursors; + cursor-theme = "Bibata-Modern-Classic"; + cursor-pkg = pkgs.bibata-cursors; in { home = {