blob: f35b469578d334e5c6dbe762d9e36d51984a5bba (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
|
{ config, lib, ... }:
let
cfg = config.wilkuu.services.uptimekuma;
hostname = config.networking.hostName;
in
{
options.wilkuu.services.uptimekuma = with lib; {
domain = mkOption {
type = types.str;
default = "uptime.${hostname}.local";
example = "uptime.wilkuu.xyz";
description = "Domain for http connections.";
};
doACME = mkEnableOption "Enable ACME for uptime kuma here";
enable = mkEnableOption "Enable the uptime-kuma service";
dataDir = mkOption {
type = types.path;
description = "Storage localtion for uptime kuma data, currently ignored, because nixpkgs sucks";
default = "/srv/data/uptimekuma";
example = "/srv/data/uptimekuma";
};
};
config = lib.mkIf cfg.enable ({
networking.hosts = {
"127.0.0.1" = [ cfg.domain ];
};
users.users.uptimekuma = {
isSystemUser = true;
group = "uptimekuma";
};
users.groups.uptimekuma = { };
systemd.services.uptime-kuma.serviceConfig.User = "uptimekuma";
systemd.services.uptime-kuma.after = [ "mysql.service" ];
# sops.secrets =
# (lib.genAttrs (map toSops secrets)
# (name: {
# sopsFile = sopsPath;
# mode = "0440";
# owner = "uptime-kuma";
# }));
services.nginx.virtualHosts."${cfg.domain}" = {
addSSL = cfg.doACME;
enableACME = cfg.doACME;
locations."/" = {
proxyPass = "http://localhost:3111";
recommendedProxySettings = true;
};
};
wilkuu.services.mysql =
let
user = config.systemd.services.uptime-kuma.serviceConfig.User;
in
{
unix_users = [ user ];
databases.uptimekuma = {
enable = true;
allowedUsers = [ user ];
};
};
services.uptime-kuma = {
enable = true;
settings = {
UPTIME_KUMA_PORT = "3111";
UPTIME_KUMA_HOST = "127.0.0.1";
UPTIME_KUMA_DB_TYPE = "sqlite";
#UPTIME_KUMA_DB_SOCKET = "/run/mysqld/mysqld.sock";
#UPTIME_KUMA_DB_USERNAME = config.systemd.services.uptime-kuma.serviceConfig.User;
#UPTIME_KUMA_DB_NAME = "uptimekuma";
};
};
});
}
|