common.nix/modules/unpackerr.nix

72 lines
1.9 KiB
Nix
Raw Normal View History

2024-05-23 20:08:11 +03:00
{ config
, lib
, pkgs
, ...
}:
let
2024-03-29 22:36:02 +02:00
cfg = config.services.unpackerr;
2024-05-23 20:08:11 +03:00
in
{
2024-03-29 22:36:02 +02:00
options.services.unpackerr = {
enable = lib.mkEnableOption "unpackerr";
2024-05-23 20:08:11 +03:00
package = lib.mkPackageOption pkgs "unpackerr" { };
2024-03-29 22:36:02 +02:00
user = lib.mkOption {
type = lib.types.str;
default = "unpackerr";
description = lib.mdDoc "User account under which unpackerr runs.";
};
group = lib.mkOption {
type = lib.types.str;
default = "unpackerr";
description = lib.mdDoc "Group under which unpackerr runs.";
};
settings = lib.mkOption {
2024-05-23 20:08:11 +03:00
default = { };
2024-03-29 22:36:02 +02:00
description = "unpackerr config file";
};
environmentFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = "Useful for storing api keys like: UN_SONARR_0_API_KEY, UN_RADARR_0_API_KEY";
};
};
config = lib.mkIf cfg.enable {
systemd = {
services.unpackerr = {
enable = true;
description = "Runs unpackerr in daemon mode";
serviceConfig = {
User = cfg.user;
Group = cfg.group;
ProtectHome = "yes";
2024-05-23 20:08:11 +03:00
DeviceAllow = [ "" ];
2024-03-29 22:36:02 +02:00
LockPersonality = true;
MemoryDenyWriteExecute = true;
PrivateDevices = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
PrivateUsers = true;
ExecStart = "${lib.getExe cfg.package} -c ${(pkgs.formats.toml {}).generate "config.toml" cfg.settings}";
EnvironmentFile = cfg.environmentFile;
};
2024-05-23 20:08:11 +03:00
wantedBy = [ "default.target" ];
2024-03-29 22:36:02 +02:00
};
};
};
}