aboutsummaryrefslogtreecommitdiffstats
path: root/module/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'module/default.nix')
-rw-r--r--module/default.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/module/default.nix b/module/default.nix
new file mode 100644
index 0000000..774a361
--- /dev/null
+++ b/module/default.nix
@@ -0,0 +1,73 @@
1flake: { lib, config, pkgs, ... }:
2with lib;
3let
4 inherit (flake.packages.${pkgs.stdenv.hostPlatform.system}) icalproxy;
5
6 cfg = config.services.icalproxy;
7in {
8 options.services.icalproxy = with types; {
9 enable = mkEnableOption "icalproxy";
10 calendarUrl = mkOption {
11 type = str;
12 };
13 ignore = mkOption {
14 type = submodule {
15 options = {
16 locationRegexes = mkOption {
17 type = listOf str;
18 };
19 summaryRegexes = mkOption {
20 type = listOf str;
21 };
22 };
23 };
24 };
25 port = mkOption {
26 type = str;
27 };
28 userTokens = mkOption {
29 type = attrsOf (submodule {
30 options = {
31 hash = mkOption {
32 type = str;
33 };
34 salt = mkOption {
35 type = str;
36 };
37 };
38 });
39 };
40 };
41
42 config = mkIf cfg.enable {
43 users.users.icalproxy = {
44 description = "icalproxy service user";
45 isSystemUser = true;
46 group = "icalproxy";
47 };
48
49 users.groups.icalproxy = {};
50
51 systemd.services.icalproxy = {
52 wants = [ "network-online.target" ];
53 wantedBy = [ "multi-user.target" ];
54 environment = {
55 CONFIG_FILE = pkgs.writeText "icalproxy-config.json" (builtins.toJSON {
56 calendar_url = cfg.calendarUrl;
57 ignore = {
58 location_regexes = cfg.ignore.locationRegexes;
59 summary_regexes = cfg.ignore.summaryRegexes;
60 };
61 port = cfg.port;
62 user_tokens = cfg.userTokens;
63 });
64 };
65 serviceConfig = {
66 User = config.users.users.icalproxy.name;
67 Group = config.users.users.icalproxy.group;
68 Restart = "always";
69 ExecStart = "${lib.getBin icalproxy}/bin/icalproxy";
70 };
71 };
72 };
73}