-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.nix
42 lines (37 loc) · 1.41 KB
/
service.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
{ config, lib, pkgs, ... }:
let
breakfastbot = pkgs.callPackage ./default.nix {};
cfg = config.services.breakfastbot;
in {
options.services.breakfastbot.enable = lib.mkEnableOption "breakfastbot";
options.services.breakfastbot.telegram_api_key = lib.mkOption {
type = lib.types.str;
example = "0000:AAAABBBB";
};
config = lib.mkIf cfg.enable {
systemd.services.breakfastbot = {
description = "ASCII breakfast bot";
after = ["network-online.target"];
wantedBy = ["network-online.target"];
environment = {
BREAKFASTBOT_DATA_DIR = "/var/lib/breakfastbot";
};
serviceConfig = {
DynamicUser = "true";
PrivateDevices = "true";
ProtectKernelTunables = "true";
ProtectKernelModules = "true";
ProtectControlGroups = "true";
RestrictAddressFamilies = "AF_INET AF_INET6";
LockPersonality = "true";
RestrictRealtime = "true";
SystemCallFilter = "@system-service @network-io @signal";
SystemCallErrorNumber = "EPERM";
ExecStart = "${breakfastbot}/bin/breakfastbot ${cfg.telegram_api_key}";
StateDirectory = "breakfastbot";
Restart = "always";
RestartSec = "5";
};
};
};
}