From 47626f0fc84dc0e45d1b19fee5424a4dd703b673 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sat, 24 Aug 2024 22:05:35 +0200 Subject: [PATCH] nixos/services.postsrsd: remove `with lib;` --- nixos/modules/services/mail/postsrsd.nix | 57 +++++++++++------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/nixos/modules/services/mail/postsrsd.nix b/nixos/modules/services/mail/postsrsd.nix index 92f01dd4101e..f94d3942b5e3 100644 --- a/nixos/modules/services/mail/postsrsd.nix +++ b/nixos/modules/services/mail/postsrsd.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.postsrsd; @@ -14,67 +11,67 @@ in { services.postsrsd = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to enable the postsrsd SRS server for Postfix."; }; - secretsFile = mkOption { - type = types.path; + secretsFile = lib.mkOption { + type = lib.types.path; default = "/var/lib/postsrsd/postsrsd.secret"; description = "Secret keys used for signing and verification"; }; - domain = mkOption { - type = types.str; + domain = lib.mkOption { + type = lib.types.str; description = "Domain name for rewrite"; }; - separator = mkOption { - type = types.enum ["-" "=" "+"]; + separator = lib.mkOption { + type = lib.types.enum ["-" "=" "+"]; default = "="; description = "First separator character in generated addresses"; }; - # bindAddress = mkOption { # uncomment once 1.5 is released - # type = types.str; + # bindAddress = lib.mkOption { # uncomment once 1.5 is released + # type = lib.types.str; # default = "127.0.0.1"; # description = "Socket listen address"; # }; - forwardPort = mkOption { - type = types.int; + forwardPort = lib.mkOption { + type = lib.types.int; default = 10001; description = "Port for the forward SRS lookup"; }; - reversePort = mkOption { - type = types.int; + reversePort = lib.mkOption { + type = lib.types.int; default = 10002; description = "Port for the reverse SRS lookup"; }; - timeout = mkOption { - type = types.int; + timeout = lib.mkOption { + type = lib.types.int; default = 1800; description = "Timeout for idle client connections in seconds"; }; - excludeDomains = mkOption { - type = types.listOf types.str; + excludeDomains = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = "Origin domains to exclude from rewriting in addition to primary domain"; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "postsrsd"; description = "User for the daemon"; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "postsrsd"; description = "Group for the daemon"; }; @@ -86,18 +83,18 @@ in { ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { - services.postsrsd.domain = mkDefault config.networking.hostName; + services.postsrsd.domain = lib.mkDefault config.networking.hostName; - users.users = optionalAttrs (cfg.user == "postsrsd") { + users.users = lib.optionalAttrs (cfg.user == "postsrsd") { postsrsd = { group = cfg.group; uid = config.ids.uids.postsrsd; }; }; - users.groups = optionalAttrs (cfg.group == "postsrsd") { + users.groups = lib.optionalAttrs (cfg.group == "postsrsd") { postsrsd.gid = config.ids.gids.postsrsd; }; @@ -110,7 +107,7 @@ in { 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${concatStringsSep "," cfg.excludeDomains}"''; + 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;