From d318a15bcadf732a9ddeda0fff5bebeda3c0522d Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Mon, 27 May 2024 17:41:36 +0530 Subject: [PATCH] nixos/hypridle: init (cherry picked from commit 353aa124467c324bb7f8293544683fae0770222f) --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/wayland/hyprlock.nix | 9 +------ nixos/modules/services/wayland/hypridle.nix | 26 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 nixos/modules/services/wayland/hypridle.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index a8edc16bcb69..3a59e1245505 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1326,6 +1326,7 @@ ./services/video/unifi-video.nix ./services/video/v4l2-relayd.nix ./services/wayland/cage.nix + ./services/wayland/hypridle.nix ./services/web-apps/akkoma.nix ./services/web-apps/alps.nix ./services/web-apps/anuko-time-tracker.nix diff --git a/nixos/modules/programs/wayland/hyprlock.nix b/nixos/modules/programs/wayland/hyprlock.nix index 9eecb6b9bb8e..6c60765e80cc 100644 --- a/nixos/modules/programs/wayland/hyprlock.nix +++ b/nixos/modules/programs/wayland/hyprlock.nix @@ -7,22 +7,15 @@ in options.programs.hyprlock = { enable = lib.mkEnableOption "hyprlock, Hyprland's GPU-accelerated screen locking utility"; package = lib.mkPackageOption pkgs "hyprlock" { }; - hypridlePackage = lib.mkPackageOption pkgs "hypridle" { }; }; config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package - cfg.hypridlePackage ]; # Hyprlock needs Hypridle systemd service to be running to detect idle time - systemd.user.services.hypridle = { - description = "Hypridle idle daemon"; - wantedBy = [ "graphical-session.target" ]; - partOf = [ "graphical-session.target" ]; - script = lib.getExe cfg.hypridlePackage; - }; + services.hypridle.enable = true; # Hyprlock needs PAM access to authenticate, else it fallbacks to su security.pam.services.hyprlock = {}; diff --git a/nixos/modules/services/wayland/hypridle.nix b/nixos/modules/services/wayland/hypridle.nix new file mode 100644 index 000000000000..5442802df987 --- /dev/null +++ b/nixos/modules/services/wayland/hypridle.nix @@ -0,0 +1,26 @@ +{ lib, pkgs, config, ... }: + +let + cfg = config.services.hypridle; +in +{ + options.services.hypridle = { + enable = lib.mkEnableOption "hypridle, Hyprland's idle daemon"; + package = lib.mkPackageOption pkgs "hypridle" { }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ + cfg.package + ]; + + systemd.user.services.hypridle = { + description = "Hypridle idle daemon"; + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + script = lib.getExe cfg.package; + }; + }; + + meta.maintainers = with lib.maintainers; [ johnrtitor ]; +}