rimgo: add module

This commit is contained in:
Quantenzitrone 2023-09-13 14:06:11 +02:00 committed by Weijia Wang
parent 264cd9ebfa
commit f857cfd5be
2 changed files with 108 additions and 0 deletions

View file

@ -1284,6 +1284,7 @@
./services/web-apps/powerdns-admin.nix ./services/web-apps/powerdns-admin.nix
./services/web-apps/prosody-filer.nix ./services/web-apps/prosody-filer.nix
./services/web-apps/restya-board.nix ./services/web-apps/restya-board.nix
./services/web-apps/rimgo.nix
./services/web-apps/sftpgo.nix ./services/web-apps/sftpgo.nix
./services/web-apps/rss-bridge.nix ./services/web-apps/rss-bridge.nix
./services/web-apps/selfoss.nix ./services/web-apps/selfoss.nix

View file

@ -0,0 +1,107 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.rimgo;
inherit (lib)
mkOption
mkEnableOption
mkPackageOption
mkDefault
mkIf
types
literalExpression
optionalString
getExe
mapAttrs
;
in
{
options.services.rimgo = {
enable = mkEnableOption "rimgo";
package = mkPackageOption pkgs "rimgo" { };
settings = mkOption {
type = types.submodule {
freeformType = with types; attrsOf str;
options = {
PORT = mkOption {
type = types.port;
default = 3000;
example = 69420;
description = "The port to use.";
};
ADDRESS = mkOption {
type = types.str;
default = "127.0.0.1";
example = "1.1.1.1";
description = "The address to listen on.";
};
};
};
example = literalExpression ''
{
PORT = 69420;
FORCE_WEBP = "1";
}
'';
description = ''
Settings for rimgo, see [the official documentation](https://rimgo.codeberg.page/docs/usage/configuration/) for supported options.
'';
};
};
config = mkIf cfg.enable {
systemd.services.rimgo = {
description = "Rimgo";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
environment = mapAttrs (_: toString) cfg.settings;
serviceConfig = {
ExecStart = getExe cfg.package;
AmbientCapabilities = mkIf (cfg.settings.PORT < 1024) [
"CAP_NET_BIND_SERVICE"
];
DynamicUser = true;
Restart = "on-failure";
RestartSec = "5s";
CapabilityBoundingSet = [
(optionalString (cfg.settings.PORT < 1024) "CAP_NET_BIND_SERVICE")
];
DeviceAllow = [ "" ];
LockPersonality = true;
MemoryDenyWriteExecute = true;
PrivateDevices = true;
PrivateUsers = cfg.settings.PORT >= 1024;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@privileged"
];
UMask = "0077";
};
};
};
meta = {
maintainers = with lib.maintainers; [ quantenzitrone ];
};
}