zaphyra's git: tgcNUR

fork of https://git.transgirl.cafe/zaphoid/tgc-nix-user-repository

commit d863309659891446776c4b7adb3f2139f4915cda
parent c5b76619e7584c1239709cd4201e223147d93581
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Tue, 26 Aug 2025 12:48:37 +0200

homeManagerModules/programs: add `gtklock`
1 file changed, 99 insertions(+), 0 deletions(-)
A
homeManagerModules/programs/gtklock/default.nix
|
99
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/homeManagerModules/programs/gtklock/default.nix b/homeManagerModules/programs/gtklock/default.nix
@@ -0,0 +1,99 @@
+{ tgcMaintainers, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
+
+let
+  inherit (lib) types;
+
+  cfg = config.tgc.programs.gtklock;
+
+  configFormat = pkgs.formats.ini {
+    listToValue = builtins.concatStringsSep ";";
+  };
+
+  configFile = configFormat.generate "gtklock-config.ini" cfg.settings;
+
+in
+{
+
+  meta.maintainers = [ tgcMaintainers.zaphyra ];
+
+  options.tgc.programs.gtklock = {
+    enable = lib.mkEnableOption "gtklock, a GTK-based lockscreen for Wayland";
+
+    package = lib.mkPackageOption pkgs "gtklock" { };
+
+    systemd.enable = lib.mkEnableOption "Enable systemd user service (can be used with e.g. systemd-lock-handler)";
+
+    settings = lib.mkOption {
+      type = configFormat.type;
+      example = lib.literalExpression ''
+        {
+          main = {
+            idle-hide = true;
+            idle-timeout = 10;
+          };
+        }'';
+      description = ''
+        Configuration for gtklock.
+        See [`gtklock(1)`](https://github.com/jovanlanik/gtklock/blob/master/man/gtklock.1.scd) man page for details.
+      '';
+    };
+
+    style = lib.mkOption {
+      type = with types; nullOr str;
+      default = null;
+      description = ''
+        CSS Stylesheet for gtklock.
+        See [gtklock's wiki](https://github.com/jovanlanik/gtklock/wiki#Styling) for details.
+      '';
+    };
+
+    modules = lib.mkOption {
+      type = with types; listOf package;
+      default = [ ];
+      example = lib.literalExpression ''
+        with pkgs; [
+          gtklock-playerctl-module
+          gtklock-powerbar-module
+          gtklock-userinfo-module
+        ]'';
+      description = "gtklock modules to load.";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    tgc.programs.gtklock.settings.main = {
+      style = lib.mkIf (cfg.style != null) "${pkgs.writeText "style.css" cfg.style}";
+
+      modules = lib.mkIf (cfg.modules != [ ]) (
+        map (pkg: "${pkg}/lib/gtklock/${lib.removePrefix "gtklock-" pkg.pname}.so") cfg.modules
+      );
+    };
+
+    xdg.configFile."gtklock/config.ini" = lib.mkIf (cfg.settings != { }) { source = configFile; };
+
+    home.packages = [ cfg.package ];
+
+    systemd.user.services.gtklock = lib.mkIf cfg.systemd.enable {
+      Unit = {
+        Description = "GTK-based lockscreen for Wayland";
+        Documentation = "https://github.com/jovanlanik/gtklock";
+        OnSuccess = [ "unlock.target" ];
+        PartOf = [ "lock.target" ];
+        After = [ "lock.target" ];
+      };
+      Service = {
+        ExecStart = lib.getExe cfg.package;
+        Restart = "on-failure";
+        RestartSec = 0;
+      };
+      Install.WantedBy = [ "lock.target" ];
+    };
+  };
+
+}