blob: 39f5bef14df8ab7225442d70948a3ce6840ba638 (
plain) (
tree)
|
|
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.fcuny-net;
in
{
options.services.fcuny-net = {
enable = mkEnableOption "fcuny.net service";
package = mkPackageOption pkgs "fcuny.net" { };
port = mkOption {
type = types.port;
default = 8070;
description = "Port to listen on";
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = "Whether to open the firewall for the goget service";
};
};
config = mkIf cfg.enable {
systemd.services.fcuny.net = {
description = "fcuny.net service";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
wants = [ "network.target" ];
serviceConfig = {
Type = "exec";
DynamicUser = true;
ExecStart = "${cfg.package}/bin/fcuny-net";
Restart = "always";
RestartSec = "5";
# Security settings
NoNewPrivileges = true;
ProtectSystem = "strict";
ProtectHome = true;
PrivateTmp = true;
ProtectKernelTunables = true;
ProtectKernelModules = true;
ProtectControlGroups = true;
RestrictSUIDSGID = true;
RestrictRealtime = true;
RestrictNamespaces = true;
LockPersonality = true;
MemoryDenyWriteExecute = true;
};
};
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ];
};
};
}
|