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 
{ tgcFlake, tgcMaintainers, ... }:
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.services.dssd;
  busName = "org.freedesktop.secrets";

in
{
  meta.maintainers = [ tgcMaintainers.zaphyra ];

  options.services.dssd = {
    enable = lib.mkEnableOption "Dead Simple libSecret Daemon";
    package = lib.mkPackageOption tgcFlake.packages.${pkgs.system} "dssd" { };
  };

  config = lib.mkIf cfg.enable {
    assertions = [
      (lib.hm.assertions.assertPlatform "services.dssd" pkgs lib.platforms.linux)
      {
        assertion = !config.services.gnome-keyring.enable;
        message = ''
          Only one secrets service per user can be enabled at a time.
          Other services enabled:
          - gnome-keyring
        '';
      }
    ];

    dbus.packages = [ cfg.package ];

    systemd.user.services.dssd = {
      Unit = {
        Description = "Dead Simple Secret Daemon";
        Documentation = "https://github.com/ylxdzsw/dssd";
      };

      Service = {
        Type = "dbus";
        ExecStart = lib.getExe cfg.package;
        BusName = busName;
      };
    };
  };

}