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 = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "local-fs.target" "network.target" ];
|
||||
systemd = {
|
||||
packages = [ cfg.package ];
|
||||
services.stalwart-mail = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "local-fs.target" "network.target" ];
|
||||
|
||||
preStart = if useLegacyStorage then ''
|
||||
mkdir -p ${dataDir}/{queue,reports,data/blobs}
|
||||
'' else ''
|
||||
mkdir -p ${dataDir}/{queue,reports,db}
|
||||
'';
|
||||
preStart = if useLegacyStorage then ''
|
||||
mkdir -p ${dataDir}/{queue,reports,data/blobs}
|
||||
'' else ''
|
||||
mkdir -p ${dataDir}/{queue,reports,db}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${cfg.package}/bin/stalwart-mail --config=${configFile}";
|
||||
serviceConfig = {
|
||||
ExecStart = [
|
||||
""
|
||||
"${cfg.package}/bin/stalwart-mail --config=${configFile}"
|
||||
];
|
||||
|
||||
# Base from template resources/systemd/stalwart-mail.service
|
||||
Type = "simple";
|
||||
LimitNOFILE = 65536;
|
||||
KillMode = "process";
|
||||
KillSignal = "SIGINT";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
SyslogIdentifier = "stalwart-mail";
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
|
||||
User = "stalwart-mail";
|
||||
Group = "stalwart-mail";
|
||||
StateDirectory = "stalwart-mail";
|
||||
StateDirectory = "stalwart-mail";
|
||||
|
||||
# Bind standard privileged ports
|
||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||
# Bind standard privileged ports
|
||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||
|
||||
# Hardening
|
||||
DeviceAllow = [ "" ];
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
PrivateDevices = true;
|
||||
PrivateUsers = false; # incompatible with CAP_NET_BIND_SERVICE
|
||||
ProcSubset = "pid";
|
||||
PrivateTmp = true;
|
||||
ProtectClock = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHome = true;
|
||||
ProtectHostname = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectProc = "invisible";
|
||||
ProtectSystem = "strict";
|
||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
||||
UMask = "0077";
|
||||
# Hardening
|
||||
DeviceAllow = [ "" ];
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
PrivateDevices = true;
|
||||
PrivateUsers = false; # incompatible with CAP_NET_BIND_SERVICE
|
||||
ProcSubset = "pid";
|
||||
PrivateTmp = true;
|
||||
ProtectClock = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHome = true;
|
||||
ProtectHostname = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectProc = "invisible";
|
||||
ProtectSystem = "strict";
|
||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
||||
UMask = "0077";
|
||||
};
|
||||
unitConfig.ConditionPathExists = [
|
||||
""
|
||||
"${configFile}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -62,6 +62,13 @@ rustPlatform.buildRustPackage {
|
||||
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
|
||||
doCheck = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user