mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
56 lines
1.3 KiB
Nix
56 lines
1.3 KiB
Nix
{ config
|
|
, pkgs
|
|
, lib
|
|
, ...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.homepage-dashboard;
|
|
in
|
|
{
|
|
options = {
|
|
services.homepage-dashboard = {
|
|
enable = lib.mkEnableOption (lib.mdDoc "Homepage Dashboard");
|
|
|
|
package = lib.mkPackageOption 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 ];
|
|
};
|
|
};
|
|
}
|