2022-01-13 20:06:32 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.prosody-filer;
|
|
|
|
|
|
|
|
settingsFormat = pkgs.formats.toml { };
|
|
|
|
configFile = settingsFormat.generate "prosody-filer.toml" cfg.settings;
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.prosody-filer = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Prosody Filer XMPP upload file server");
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
settings = mkOption {
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-13 20:06:32 +00:00
|
|
|
Configuration for Prosody Filer.
|
2022-08-12 12:06:08 +00:00
|
|
|
Refer to <https://github.com/ThomasLeister/prosody-filer#configure-prosody-filer> for details on supported values.
|
2022-01-13 20:06:32 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
type = settingsFormat.type;
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
example = {
|
|
|
|
secret = "mysecret";
|
|
|
|
storeDir = "/srv/http/nginx/prosody-upload";
|
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
defaultText = literalExpression ''
|
|
|
|
{
|
|
|
|
listenport = mkDefault "127.0.0.1:5050";
|
|
|
|
uploadSubDir = mkDefault "upload/";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.prosody-filer.settings = {
|
|
|
|
listenport = mkDefault "127.0.0.1:5050";
|
|
|
|
uploadSubDir = mkDefault "upload/";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.prosody-filer = {
|
|
|
|
group = "prosody-filer";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.prosody-filer = { };
|
|
|
|
|
|
|
|
systemd.services.prosody-filer = {
|
|
|
|
description = "Prosody file upload server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = "prosody-filer";
|
|
|
|
Group = "prosody-filer";
|
|
|
|
ExecStart = "${pkgs.prosody-filer}/bin/prosody-filer -config ${configFile}";
|
|
|
|
Restart = "on-failure";
|
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectProc = "noaccess";
|
|
|
|
ProcSubset = "pid";
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
LockPersonality = true;
|
|
|
|
RemoveIPC = true;
|
|
|
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
2022-10-30 15:09:59 +00:00
|
|
|
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
2022-01-13 20:06:32 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|