From a654a6b9b65f67819c708cdf8092a65776f2b527 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Fri, 13 Jun 2025 21:46:18 +0800 Subject: [PATCH] refactor(nixos/desktop): move hyprlock config to nixos module --- modules/home/desktop/lockscreen/default.nix | 47 ------------------ .../desktop/lockscreen/hyprlock/default.nix | 49 +++++++++++++++++++ modules/nixos/desktop/default.nix | 1 - modules/nixos/desktop/lockscreen/default.nix | 12 ++++- systems/x86_64-linux/desktop.nix | 2 +- 5 files changed, 60 insertions(+), 51 deletions(-) delete mode 100644 modules/home/desktop/lockscreen/default.nix create mode 100644 modules/home/desktop/lockscreen/hyprlock/default.nix diff --git a/modules/home/desktop/lockscreen/default.nix b/modules/home/desktop/lockscreen/default.nix deleted file mode 100644 index 8003c52..0000000 --- a/modules/home/desktop/lockscreen/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - osConfig, - lib, - ... -}: -{ - config = lib.mkMerge [ - (lib.mkIf (osConfig.desktop.lockscreen == "hyprlock") { - home.sessionVariables.LOCKSCREEN = "hyprlock"; - programs.hyprlock = { - enable = true; - settings = { - general.hide_cursor = true; - general.ignore_empty_input = true; - - background = { - blur_passes = 5; - blur_size = 5; - }; - - label = { - text = ''hi, $USER.''; - font_size = 32; - halign = "center"; - valign = "center"; - position = "0, 0"; - zindex = 1; - shadow_passes = 5; - shadow_size = 5; - }; - - input-field = { - fade_on_empty = true; - size = "200, 45"; - halign = "center"; - valign = "center"; - position = "0, -5%"; - placeholder_text = ""; - zindex = 1; - shadow_passes = 5; - shadow_size = 5; - }; - }; - }; - }) - ]; -} diff --git a/modules/home/desktop/lockscreen/hyprlock/default.nix b/modules/home/desktop/lockscreen/hyprlock/default.nix new file mode 100644 index 0000000..0d7de98 --- /dev/null +++ b/modules/home/desktop/lockscreen/hyprlock/default.nix @@ -0,0 +1,49 @@ +{ osConfig, lib, ... }: +let + inherit (lib) singleton mkIf; + cfg = osConfig.desktop.lockscreen.hyprlock; +in +{ + config = mkIf cfg.enable { + assertions = singleton { + assertion = osConfig.security.pam.services ? hyprlock; + message = "You must add hyprlock to osConfig.security.pam.services."; + }; + home.sessionVariables.LOCKSCREEN = "hyprlock"; + programs.hyprlock = { + enable = true; + settings = { + general.hide_cursor = true; + general.ignore_empty_input = true; + + background = { + blur_passes = 5; + blur_size = 5; + }; + + label = { + text = ''hi, $USER.''; + font_size = 32; + halign = "center"; + valign = "center"; + position = "0, 0"; + zindex = 1; + shadow_passes = 5; + shadow_size = 5; + }; + + input-field = { + fade_on_empty = true; + size = "200, 45"; + halign = "center"; + valign = "center"; + position = "0, -5%"; + placeholder_text = ""; + zindex = 1; + shadow_passes = 5; + shadow_size = 5; + }; + }; + }; + }; +} diff --git a/modules/nixos/desktop/default.nix b/modules/nixos/desktop/default.nix index 914e768..7a88799 100644 --- a/modules/nixos/desktop/default.nix +++ b/modules/nixos/desktop/default.nix @@ -17,7 +17,6 @@ refresh-rate = lib.pantheon.mkStrOption; }; windowManager = lib.pantheon.mkStrOption; - lockscreen = lib.pantheon.mkStrOption; terminal = lib.pantheon.mkStrOption; notification-daemon = lib.pantheon.mkStrOption; launcher = lib.pantheon.mkStrOption; diff --git a/modules/nixos/desktop/lockscreen/default.nix b/modules/nixos/desktop/lockscreen/default.nix index ce40153..bcc94b1 100644 --- a/modules/nixos/desktop/lockscreen/default.nix +++ b/modules/nixos/desktop/lockscreen/default.nix @@ -1,7 +1,15 @@ { config, lib, ... }: +let + inherit (lib) mkEnableOption mkIf mkMerge; + cfg = config.desktop.lockscreen; +in { - config = lib.mkMerge [ - (lib.mkIf (config.desktop.lockscreen == "hyprlock") { + options.desktop.lockscreen = { + hyprlock.enable = mkEnableOption ""; + }; + + config = mkMerge [ + (mkIf cfg.hyprlock.enable { security.pam.services.hyprlock = { }; }) ]; diff --git a/systems/x86_64-linux/desktop.nix b/systems/x86_64-linux/desktop.nix index d35d20f..c7b8baf 100644 --- a/systems/x86_64-linux/desktop.nix +++ b/systems/x86_64-linux/desktop.nix @@ -7,9 +7,9 @@ "test" ]; }; + lockscreen.hyprlock.enable = true; windowManager = "hyprland"; terminal = "ghostty"; - lockscreen = "hyprlock"; notification-daemon = "mako"; launcher = "fuzzel"; status-bar = "waybar";