zaphyra's git: nixfiles

zaphyra's nixfiles

commit ec7a39aaea80c7837f8afb0b53abdc808a289280
parent 7266e7c0bcad7f83a7e67ec05cd636a7fb13a7eb
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Sat, 28 Jun 2025 11:28:41 +0200

config/nixos/modules/services: add `swaylock`
1 file changed, 42 insertions(+), 0 deletions(-)
A
config/nixos/modules/services/swaylock.nix
|
42
++++++++++++++++++++++++++++++++++++++++++
diff --git a/config/nixos/modules/services/swaylock.nix b/config/nixos/modules/services/swaylock.nix
@@ -0,0 +1,42 @@
+{
+  povSelf,
+  config,
+  lib,
+  pkgs,
+  ...
+}:
+let
+  inherit (lib) types;
+  cfg = lib.getAttrFromPath povSelf config;
+
+in
+{
+
+  options.enable = {
+    type = types.bool;
+    default = false;
+  };
+
+  config = lib.mkIf cfg.enable {
+    security.pam.services.swaylock = { };
+
+    services.systemd-lock-handler.enable = true;
+
+    home-manager.sharedModules = [
+      {
+        systemd.user.services = {
+          swaylock = {
+            Unit.OnSuccess = [ "unlock.target" ];
+            Unit.PartOf = [ "lock.target" ];
+            Unit.After = [ "lock.target" ];
+            Install.WantedBy = [ "lock.target" ];
+            Service.ExecStart = "${lib.getExe pkgs.swaylock} -i /home/zaphyra/Pictures/Backgrounds/lock.png";
+            Service.Restart = "on-failure";
+            Service.RestartSec = 0;
+          };
+        };
+      }
+    ];
+  };
+
+}