mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
Merge pull request #313634 from onny/stalwart-systemd
stalwart-mail: package und use upstream systemd unit
This commit is contained in:
commit
e45abe6d47
@ -76,63 +76,62 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.stalwart-mail = {
|
systemd = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
packages = [ cfg.package ];
|
||||||
after = [ "local-fs.target" "network.target" ];
|
services.stalwart-mail = {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "local-fs.target" "network.target" ];
|
||||||
|
|
||||||
preStart = if useLegacyStorage then ''
|
preStart = if useLegacyStorage then ''
|
||||||
mkdir -p ${dataDir}/{queue,reports,data/blobs}
|
mkdir -p ${dataDir}/{queue,reports,data/blobs}
|
||||||
'' else ''
|
'' else ''
|
||||||
mkdir -p ${dataDir}/{queue,reports,db}
|
mkdir -p ${dataDir}/{queue,reports,db}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart =
|
ExecStart = [
|
||||||
"${cfg.package}/bin/stalwart-mail --config=${configFile}";
|
""
|
||||||
|
"${cfg.package}/bin/stalwart-mail --config=${configFile}"
|
||||||
|
];
|
||||||
|
|
||||||
# Base from template resources/systemd/stalwart-mail.service
|
StandardOutput = "journal";
|
||||||
Type = "simple";
|
StandardError = "journal";
|
||||||
LimitNOFILE = 65536;
|
|
||||||
KillMode = "process";
|
|
||||||
KillSignal = "SIGINT";
|
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = 5;
|
|
||||||
StandardOutput = "journal";
|
|
||||||
StandardError = "journal";
|
|
||||||
SyslogIdentifier = "stalwart-mail";
|
|
||||||
|
|
||||||
User = "stalwart-mail";
|
StateDirectory = "stalwart-mail";
|
||||||
Group = "stalwart-mail";
|
|
||||||
StateDirectory = "stalwart-mail";
|
|
||||||
|
|
||||||
# Bind standard privileged ports
|
# Bind standard privileged ports
|
||||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||||
|
|
||||||
# Hardening
|
# Hardening
|
||||||
DeviceAllow = [ "" ];
|
DeviceAllow = [ "" ];
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
MemoryDenyWriteExecute = true;
|
MemoryDenyWriteExecute = true;
|
||||||
PrivateDevices = true;
|
PrivateDevices = true;
|
||||||
PrivateUsers = false; # incompatible with CAP_NET_BIND_SERVICE
|
PrivateUsers = false; # incompatible with CAP_NET_BIND_SERVICE
|
||||||
ProcSubset = "pid";
|
ProcSubset = "pid";
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
ProtectClock = true;
|
ProtectClock = true;
|
||||||
ProtectControlGroups = true;
|
ProtectControlGroups = true;
|
||||||
ProtectHome = true;
|
ProtectHome = true;
|
||||||
ProtectHostname = true;
|
ProtectHostname = true;
|
||||||
ProtectKernelLogs = true;
|
ProtectKernelLogs = true;
|
||||||
ProtectKernelModules = true;
|
ProtectKernelModules = true;
|
||||||
ProtectKernelTunables = true;
|
ProtectKernelTunables = true;
|
||||||
ProtectProc = "invisible";
|
ProtectProc = "invisible";
|
||||||
ProtectSystem = "strict";
|
ProtectSystem = "strict";
|
||||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||||
RestrictNamespaces = true;
|
RestrictNamespaces = true;
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
RestrictSUIDSGID = true;
|
RestrictSUIDSGID = true;
|
||||||
SystemCallArchitectures = "native";
|
SystemCallArchitectures = "native";
|
||||||
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
||||||
UMask = "0077";
|
UMask = "0077";
|
||||||
|
};
|
||||||
|
unitConfig.ConditionPathExists = [
|
||||||
|
""
|
||||||
|
"${configFile}"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,6 +62,13 @@ rustPlatform.buildRustPackage {
|
|||||||
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
|
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/lib/systemd/system
|
||||||
|
|
||||||
|
substitute resources/systemd/stalwart-mail.service $out/lib/systemd/system/stalwart-mail.service \
|
||||||
|
--replace "__PATH__" "$out"
|
||||||
|
'';
|
||||||
|
|
||||||
# Tests require reading to /etc/resolv.conf
|
# Tests require reading to /etc/resolv.conf
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user