mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-21 08:59:20 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
136 lines
3.4 KiB
Nix
136 lines
3.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
|
|
cfg = config.services.postsrsd;
|
|
|
|
in
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.postsrsd = {
|
|
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Whether to enable the postsrsd SRS server for Postfix.";
|
|
};
|
|
|
|
secretsFile = lib.mkOption {
|
|
type = lib.types.path;
|
|
default = "/var/lib/postsrsd/postsrsd.secret";
|
|
description = "Secret keys used for signing and verification";
|
|
};
|
|
|
|
domain = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Domain name for rewrite";
|
|
};
|
|
|
|
separator = lib.mkOption {
|
|
type = lib.types.enum [
|
|
"-"
|
|
"="
|
|
"+"
|
|
];
|
|
default = "=";
|
|
description = "First separator character in generated addresses";
|
|
};
|
|
|
|
# bindAddress = lib.mkOption { # uncomment once 1.5 is released
|
|
# type = lib.types.str;
|
|
# default = "127.0.0.1";
|
|
# description = "Socket listen address";
|
|
# };
|
|
|
|
forwardPort = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 10001;
|
|
description = "Port for the forward SRS lookup";
|
|
};
|
|
|
|
reversePort = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 10002;
|
|
description = "Port for the reverse SRS lookup";
|
|
};
|
|
|
|
timeout = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 1800;
|
|
description = "Timeout for idle client connections in seconds";
|
|
};
|
|
|
|
excludeDomains = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
description = "Origin domains to exclude from rewriting in addition to primary domain";
|
|
};
|
|
|
|
user = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "postsrsd";
|
|
description = "User for the daemon";
|
|
};
|
|
|
|
group = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "postsrsd";
|
|
description = "Group for the daemon";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.postsrsd.domain = lib.mkDefault config.networking.hostName;
|
|
|
|
users.users = lib.optionalAttrs (cfg.user == "postsrsd") {
|
|
postsrsd = {
|
|
group = cfg.group;
|
|
uid = config.ids.uids.postsrsd;
|
|
};
|
|
};
|
|
|
|
users.groups = lib.optionalAttrs (cfg.group == "postsrsd") {
|
|
postsrsd.gid = config.ids.gids.postsrsd;
|
|
};
|
|
|
|
systemd.services.postsrsd = {
|
|
description = "PostSRSd SRS rewriting server";
|
|
after = [ "network.target" ];
|
|
before = [ "postfix.service" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ pkgs.coreutils ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = ''${pkgs.postsrsd}/sbin/postsrsd "-s${cfg.secretsFile}" "-d${cfg.domain}" -a${cfg.separator} -f${toString cfg.forwardPort} -r${toString cfg.reversePort} -t${toString cfg.timeout} "-X${lib.concatStringsSep "," cfg.excludeDomains}"'';
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
PermissionsStartOnly = true;
|
|
};
|
|
|
|
preStart = ''
|
|
if [ ! -e "${cfg.secretsFile}" ]; then
|
|
echo "WARNING: secrets file not found, autogenerating!"
|
|
DIR="$(dirname "${cfg.secretsFile}")"
|
|
install -m 750 -o ${cfg.user} -g ${cfg.group} -d "$DIR"
|
|
install -m 600 -o ${cfg.user} -g ${cfg.group} <(dd if=/dev/random bs=18 count=1 | base64) "${cfg.secretsFile}"
|
|
fi
|
|
'';
|
|
};
|
|
|
|
};
|
|
}
|