blob: 909481873704b0303a6bf25e4ba93930b5ec3bf1 (
plain) (
blame)
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
66
67
|
# Run the owothia IRC bot.
{ depot, config, lib, pkgs, ... }:
let
cfg = config.services.depot.owothia;
description = "owothia - i'm a service owo";
in {
options.services.depot.owothia = {
enable = lib.mkEnableOption description;
secretsFile = lib.mkOption {
type = lib.types.str;
description = "File path from which systemd should read secrets";
default = "/etc/secrets/owothia";
};
owoChance = lib.mkOption {
type = lib.types.int;
description = "How likely is owo?";
default = 200;
};
ircServer = lib.mkOption {
type = lib.types.str;
description = "IRC server hostname";
};
ircPort = lib.mkOption {
type = lib.types.int;
description = "IRC server port";
};
ircIdent = lib.mkOption {
type = lib.types.str;
description = "IRC username";
default = "owothia";
};
ircChannels = lib.mkOption {
type = with lib.types; listOf str;
description = "IRC channels to join";
default = [ "#tvl" ];
};
};
config = lib.mkIf cfg.enable {
systemd.services.owothia = {
inherit description;
script = "${depot.fun.owothia}/bin/owothia";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
Restart = "always";
EnvironmentFile = cfg.secretsFile;
};
environment = {
OWO_CHANCE = toString cfg.owoChance;
IRC_SERVER = cfg.ircServer;
IRC_PORT = toString cfg.ircPort;
IRC_IDENT = cfg.ircIdent;
IRC_CHANNELS = builtins.toJSON cfg.ircChannels;
};
};
};
}
|