zaphyra's git: tgcNUR

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

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
{ tgcFlake, ... }:
{
  config,
  pkgs,
  lib,
  ...
}:

let
  inherit (lib) types;
  cfg = config.tgc.services.shaderbg;

in
{

  options.tgc.services.shaderbg = {
    enable = lib.mkEnableOption "";
    package = lib.mkPackageOption tgcFlake.packages.${pkgs.system} "shaderbg" { };
    systemd.enable = lib.mkOption {
      type = types.bool;
      default = true;
      example = false;
      description = "Enable shaderbg's Systemd Unit.";
    };
    systemd.output = lib.mkOption {
      type = types.str;
      default = "*";
      example = "*";
      description = "Output to use";
    };
    systemd.extraArgs = lib.mkOption {
      type = with types; listOf str;
      default = [ ];
      example = [
        "--fps"
        "10"
        "--layer"
        "background"
      ];
    };
    systemd.shaderFile = lib.mkOption {
      type =
        with types;
        oneOf [
          path
          str
        ];
      example = "./example.frag";
    };
  };

  config = lib.mkIf cfg.enable {
    home.packages = [ cfg.package ];

    systemd.user.services.shaderbg = lib.mkIf cfg.systemd.enable {
      Unit = {
        Description = "A live wallpaper program for Sway and other compositors with wlr-layer-shell support.";
        After = [ "graphical-session-pre.target" ];
        PartOf = [ "graphical-session.target" ];
      };
      Service = {
        Restart = "on-failure";
        RestartSec = 5;
        ExecStart = lib.concatStringsSep " " [
          (lib.getExe cfg.package)
          (lib.escapeShellArgs cfg.systemd.extraArgs)
          cfg.systemd.output
          cfg.systemd.shaderFile
        ];
      };
      Install.WantedBy = [ "graphical-session.target" ];
    };
  };

}