From 2cd1a0a73026dc61d8c1d672ce42343c4c097482 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sat, 21 Oct 2023 19:40:46 +0200 Subject: [PATCH] pinwheel: Add `enable` option to `swaylock` module --- hosts/pinwheel/configuration.nix | 1 + hosts/pinwheel/modules/swaylock/default.nix | 59 ++++++++++++--------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/hosts/pinwheel/configuration.nix b/hosts/pinwheel/configuration.nix index d6e12bb..ca4c9e0 100644 --- a/hosts/pinwheel/configuration.nix +++ b/hosts/pinwheel/configuration.nix @@ -78,6 +78,7 @@ nix-index.enable = true; greetd.enable = true; hyprland.enable = true; + swaylock.enable = true; git.enable = true; openvpn.enable = true; go.enable = true; diff --git a/hosts/pinwheel/modules/swaylock/default.nix b/hosts/pinwheel/modules/swaylock/default.nix index 4931b40..4e16b65 100644 --- a/hosts/pinwheel/modules/swaylock/default.nix +++ b/hosts/pinwheel/modules/swaylock/default.nix @@ -1,36 +1,45 @@ { pkgs, lib, config, ... }: let + enabled = config.mod.swaylock.enable; hyprlandEnabled = config.mod.hyprland.enable; in { - home-manager.users.alex = { - programs.swaylock = { - enable = true; - - settings = { - color = "000000"; - indicator-idle-visible = false; - show-failed-attempts = true; - }; - }; - - wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled { - settings = { - bind = [ - "$mod SHIFT, x, exec, ${pkgs.swaylock}/bin/swaylock -f && systemctl suspend" - "$mod, x, exec, ${pkgs.playerctl}/bin/playerctl -p spotify pause; ${pkgs.swaylock}/bin/swaylock" - ]; - }; + options = { + mod.swaylock = { + enable = lib.mkEnableOption "enable swaylock module"; }; }; - security = { - polkit.enable = true; + config = lib.mkIf enabled { + home-manager.users.alex = { + programs.swaylock = { + enable = true; - pam.services.swaylock.text = '' - # PAM configuration file for the swaylock screen locker. By default, it includes - # the 'login' configuration file (see /etc/pam.d/login) - auth include login - ''; + settings = { + color = "000000"; + indicator-idle-visible = false; + show-failed-attempts = true; + }; + }; + + wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled { + settings = { + bind = [ + "$mod SHIFT, x, exec, ${pkgs.swaylock}/bin/swaylock -f && systemctl suspend" + "$mod, x, exec, ${pkgs.playerctl}/bin/playerctl -p spotify pause; ${pkgs.swaylock}/bin/swaylock" + ]; + }; + }; + }; + + security = { + polkit.enable = true; + + pam.services.swaylock.text = '' + # PAM configuration file for the swaylock screen locker. By default, it includes + # the 'login' configuration file (see /etc/pam.d/login) + auth include login + ''; + }; }; }