fork/home-manager

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

midchildanmodules: add platform assertions17dc5939

master
1.9 KiB82 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.services.kdeconnect;
8  package = pkgs.plasma5Packages.kdeconnect-kde;
9
10in {
11  meta.maintainers = [ maintainers.adisbladis ];
12
13  options = {
14    services.kdeconnect = {
15      enable = mkEnableOption "KDE connect";
16
17      indicator = mkOption {
18        type = types.bool;
19        default = false;
20        description = "Whether to enable kdeconnect-indicator service.";
21      };
22
23    };
24  };
25
26  config = mkMerge [
27    (mkIf cfg.enable {
28      home.packages = [ package ];
29
30      assertions = [
31        (hm.assertions.assertPlatform "services.kdeconnect" pkgs
32          platforms.linux)
33      ];
34
35      systemd.user.services.kdeconnect = {
36        Unit = {
37          Description =
38            "Adds communication between your desktop and your smartphone";
39          After = [ "graphical-session-pre.target" ];
40          PartOf = [ "graphical-session.target" ];
41        };
42
43        Install = { WantedBy = [ "graphical-session.target" ]; };
44
45        Service = {
46          Environment = "PATH=${config.home.profileDirectory}/bin";
47          ExecStart = "${package}/libexec/kdeconnectd";
48          Restart = "on-abort";
49        };
50      };
51    })
52
53    (mkIf cfg.indicator {
54      assertions = [
55        (hm.assertions.assertPlatform "services.kdeconnect" pkgs
56          platforms.linux)
57      ];
58
59      systemd.user.services.kdeconnect-indicator = {
60        Unit = {
61          Description = "kdeconnect-indicator";
62          After = [
63            "graphical-session-pre.target"
64            "polybar.service"
65            "taffybar.service"
66            "stalonetray.service"
67          ];
68          PartOf = [ "graphical-session.target" ];
69        };
70
71        Install = { WantedBy = [ "graphical-session.target" ]; };
72
73        Service = {
74          Environment = "PATH=${config.home.profileDirectory}/bin";
75          ExecStart = "${package}/bin/kdeconnect-indicator";
76          Restart = "on-abort";
77        };
78      };
79    })
80
81  ];
82}