fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.0 KiB79 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4let cfg = config.services.barrier;
5in {
6
7  meta.maintainers = with maintainers; [ kritnich ];
8
9  imports = [
10    (mkRemovedOptionModule [ "services" "barrier" "client" "tray" ] ''
11      The tray option is non-functional and has been removed.
12    '')
13  ];
14
15  options.services.barrier = {
16
17    client = {
18
19      enable = mkEnableOption "Barrier Client daemon";
20
21      name = mkOption {
22        type = types.nullOr types.str;
23        default = null;
24        description = ''
25          Screen name of client. Defaults to hostname.
26        '';
27      };
28
29      server = mkOption {
30        type = types.str;
31        description = ''
32          Server to connect to formatted as
33          `<host>[:<port>]`.
34          Port defaults to `24800`.
35        '';
36      };
37
38      enableCrypto = mkEnableOption "crypto (SSL) plugin" // {
39        default = true;
40      };
41
42      enableDragDrop = mkEnableOption "file drag &amp; drop";
43
44      extraFlags = mkOption {
45        type = types.listOf types.str;
46        default = [ "-f" ];
47        defaultText = literalExpression ''[ "-f" ]'';
48        description = ''
49          Additional flags to pass to {command}`barrierc`.
50          See {command}`barrierc --help`.
51        '';
52      };
53
54    };
55  };
56
57  config = mkIf cfg.client.enable {
58    assertions = [
59      (lib.hm.assertions.assertPlatform "services.barrier" pkgs
60        lib.platforms.linux)
61    ];
62
63    systemd.user.services.barrierc = {
64      Unit = {
65        Description = "Barrier Client daemon";
66        After = [ "graphical-session-pre.target" ];
67        PartOf = [ "graphical-session.target" ];
68      };
69      Install.WantedBy = [ "graphical-session.target" ];
70      Service.ExecStart = with cfg.client;
71        toString ([ "${pkgs.barrier}/bin/barrierc" ]
72          ++ optional (name != null) "--name ${name}"
73          ++ optional (!enableCrypto) "--disable-crypto"
74          ++ optional enableDragDrop "--enable-drag-drop" ++ extraFlags
75          ++ [ server ]);
76    };
77  };
78
79}