-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodule.nix
65 lines (59 loc) · 1.66 KB
/
module.nix
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
self: {
config,
lib,
pkgs,
...
}: let
cfg = config.services.untis-ics-sync;
in {
options.services.untis-ics-sync = let
inherit (lib) mkEnableOption mkPackageOption mkOption types;
inherit (pkgs.stdenv.hostPlatform) system;
in {
enable = mkEnableOption "Untis ICS Sync";
package = mkPackageOption self.packages.${system} "default" {};
envFile = mkOption {
type = types.path;
description = "The environment file with credentials.";
};
user = mkOption {
type = types.str;
default = "untis-ics-sync";
description = "The user to run untis-ics-sync under.";
};
group = mkOption {
type = types.str;
default = "untis-ics-sync";
description = "The group to run untis-ics-sync under.";
};
};
config = lib.mkIf cfg.enable {
systemd.services.untis-ics-sync = {
description = "untis-ics-sync";
wantedBy = ["multi-user.target"];
wants = ["network-online.target"];
after = ["network-online.target"];
serviceConfig = {
Restart = "on-failure";
ExecStart = "${lib.getExe cfg.package}";
Environment = [
"BULL_REDIS_PATH=${config.services.redis.servers.untis-ics-sync.unixSocket}"
];
EnvironmentFile = cfg.envFile;
User = cfg.user;
Group = cfg.group;
};
};
services.redis.servers.untis-ics-sync = {
enable = true;
user = cfg.user;
};
users = {
users.untis-ics-sync = lib.mkIf (cfg.user == "untis-ics-sync") {
isSystemUser = true;
group = cfg.group;
};
groups.untis-ics-sync = lib.mkIf (cfg.group == "untis-ics-sync") {};
};
};
}