blob: e685712534333f6fe39fad45bd9fe0398737cbd1 (
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
|
{ config
, pkgs
, lib
, ...
}:
let
cfg = config.services.homepage-dashboard;
in
{
options = {
services.homepage-dashboard = {
enable = lib.mkEnableOption (lib.mdDoc "Homepage Dashboard");
package = lib.mkPackageOptionMD pkgs "homepage-dashboard" { };
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "Open ports in the firewall for Homepage.";
};
listenPort = lib.mkOption {
type = lib.types.int;
default = 8082;
description = lib.mdDoc "Port for Homepage to bind to.";
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.homepage-dashboard = {
description = "Homepage Dashboard";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment = {
HOMEPAGE_CONFIG_DIR = "/var/lib/homepage-dashboard";
PORT = "${toString cfg.listenPort}";
};
serviceConfig = {
Type = "simple";
DynamicUser = true;
StateDirectory = "homepage-dashboard";
ExecStart = "${lib.getExe cfg.package}";
Restart = "on-failure";
};
};
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.listenPort ];
};
};
}
|