diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-04-20 12:13:35 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-06-09 14:51:16 +0000 |
commit | 7014df2256694d97093d6f2bb1db340d346dea88 (patch) | |
tree | 739b843819457508e7b4bced5d5a3e6a94a18ab0 /nixpkgs | |
parent | 5c5963660bb5a35cb9e6ec6109765b4dbfd2e164 (diff) | |
download | nixlib-7014df2256694d97093d6f2bb1db340d346dea88.tar nixlib-7014df2256694d97093d6f2bb1db340d346dea88.tar.gz nixlib-7014df2256694d97093d6f2bb1db340d346dea88.tar.bz2 nixlib-7014df2256694d97093d6f2bb1db340d346dea88.tar.lz nixlib-7014df2256694d97093d6f2bb1db340d346dea88.tar.xz nixlib-7014df2256694d97093d6f2bb1db340d346dea88.tar.zst nixlib-7014df2256694d97093d6f2bb1db340d346dea88.zip |
nixos/public-inbox: even closer to upstream
Diffstat (limited to 'nixpkgs')
-rw-r--r-- | nixpkgs/nixos/modules/services/mail/public-inbox.nix | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/nixpkgs/nixos/modules/services/mail/public-inbox.nix b/nixpkgs/nixos/modules/services/mail/public-inbox.nix index c45ea7385b96..9e016e6e533b 100644 --- a/nixpkgs/nixos/modules/services/mail/public-inbox.nix +++ b/nixpkgs/nixos/modules/services/mail/public-inbox.nix @@ -6,9 +6,8 @@ let cfg = config.services.public-inbox; stateDir = "/var/lib/public-inbox"; - inboxesDir = "${stateDir}/inboxes"; - inboxPath = name: "${inboxesDir}/${name}"; - gitPath = name: "${inboxPath name}/all.git"; + manref = name: vol: "<citerefentry><refentrytitle>${name}</refentrytitle><manvolnum>${toString vol}</manvolnum></citerefentry>"; + inboxPath = name: "${stateDir}/inboxes/${name}"; inboxes = mapAttrs (name: inbox: (recursiveUpdate { @@ -45,12 +44,10 @@ let ${pkgs.git}/bin/git config --add --file $out ${escapeShellArgs [ key val ]} ''; - configFile = pkgs.runCommand "public-inbox-config" {} - (concatStrings (map ({ name, value }: gitConfig name value) configList)); - environment = { PI_EMERGENCY = "${stateDir}/emergency"; - PI_CONFIG = configFile; + PI_CONFIG = pkgs.runCommand "public-inbox-config" {} + (concatStrings (map ({ name, value }: gitConfig name value) configList)); }; envList = mapAttrsToList (n: v: "${n}=${v}") environment; @@ -75,9 +72,6 @@ let } ''; - descriptionFile = { description, ... }: - pkgs.writeText "description" description; - enableWatch = (any (i: i.watch != []) (attrValues cfg.inboxes)) || (cfg.watch.watchSpam != null); @@ -107,24 +101,23 @@ in description = '' Inboxes to configure, where attribute names are inbox names. ''; - type = with types; loaOf (submodule { + type = types.loaOf (types.submodule { options = { address = mkOption { - type = listOf str; + type = with types; listOf str; example = "example-discuss@example.org"; + description = "The email addresses of the public-inbox."; }; url = mkOption { - type = nullOr str; + type = with types; nullOr str; default = null; example = "https://example.org/lists/example-discuss"; - description = '' - URL where this inbox can be accessed over HTTP - ''; + description = "URL where this inbox can be accessed over HTTP."; }; description = mkOption { - type = str; + type = types.str; example = "user/dev discussion of public-inbox itself"; description = '' User-visible description for the repository @@ -132,7 +125,7 @@ in }; config = mkOption { - type = attrs; + type = types.attrs; default = {}; description = '' Additional structured config for the inbox @@ -140,7 +133,7 @@ in }; newsgroup = mkOption { - type = nullOr str; + type = with types; nullOr str; default = null; description = '' NNTP group name for the inbox @@ -148,20 +141,18 @@ in }; watch = mkOption { - type = listOf str; + type = with types; listOf str; default = []; - description = '' - Paths for public-inbox-watch(1) to monitor for new mail - ''; + description = "Paths for ${manref "public-inbox-watch" 1} to monitor for new mail."; example = [ "maildir:/path/to/test.example.com.git" ]; }; watchHeader = mkOption { - type = nullOr str; + type = with types; nullOr str; default = null; example = "List-Id:<test@example.com>"; description = '' - If specified, public-inbox-watch(1) will only process + If specified, ${manref "public-inbox-watch" 1} will only process mail containing a matching header. ''; }; @@ -170,19 +161,18 @@ in }; mda = { + enable = mkEnableOption "the public-inbox Mail Delivery agent"; args = mkOption { type = with types; listOf str; default = []; - description = '' - Command-line arguments to pass to public-inbox-mda(1). - ''; + description = "Command-line arguments to pass to ${manref "public-inbox-mda" 1}."; }; spamCheck = mkOption { type = with types; nullOr (enum [ "spamc" ]); default = "spamc"; description = '' - If set to spamc, public-inbox-mda(1) will filter spam + If set to spamc, ${manref "public-inbox-mda" 1} will filter spam using SpamAssassin ''; }; @@ -193,7 +183,7 @@ in type = with types; nullOr (enum [ "spamc" ]); default = "spamc"; description = '' - If set to spamc, public-inbox-watch(1) will filter spam + If set to spamc, ${manref "public-inbox-watch" 1} will filter spam using SpamAssassin ''; }; @@ -225,7 +215,7 @@ in type = with types; listOf str; default = [ "/run/public-inbox-httpd.sock" ]; description = '' - systemd.socket(5) ListenStream values for the + ${manref "systemd.socket" 5} ListenStream values for the public-inbox-httpd service to listen on ''; }; @@ -236,7 +226,7 @@ in type = with types; listOf str; default = [ "0.0.0.0:119" "0.0.0.0:563" ]; description = '' - systemd.socket(5) ListenStream values for the + ${manref "systemd.socket" 5} ListenStream values for the public-inbox-nntpd service to listen on ''; }; @@ -271,9 +261,7 @@ in type = with types; listOf str; default = []; example = [ "nntp://news.public-inbox.org" "nntps://news.public-inbox.org" ]; - description = '' - NNTP URLs to this public-inbox instance - ''; + description = "NNTP URLs to this public-inbox instance"; }; wwwListing = mkOption { @@ -330,11 +318,12 @@ in |"env ${concatStringsSep " " envList} PATH=\"${makeBinPath cfg.path}:$PATH\" ${cfg.package}/bin/public-inbox-mda ${escapeShellArgs cfg.mda.args} ''; passAsFile = [ "forward" ]; - } '' + } ('' mkdir $out ln -s ${stateDir}/spamassassin $out/.spamassassin + '' + optionalString cfg.mda.enable '' cp $forwardPath $out/.forward - ''; + ''); group = "public-inbox"; isSystemUser = true; }; @@ -363,8 +352,8 @@ in inherit environment; serviceConfig.ExecStart = escapeShellArgs ( [ "${cfg.package}/bin/public-inbox-nntpd" ] ++ - (optionals (cfg.nntp.cert != null) [ "--cert" cfg.nntp.cert ]) ++ - (optionals (cfg.nntp.key != null) [ "--key" cfg.nntp.key ]) + optionals (cfg.nntp.cert != null) [ "--cert" cfg.nntp.cert ] ++ + optionals (cfg.nntp.key != null) [ "--key" cfg.nntp.key ] ); serviceConfig.NonBlocking = true; serviceConfig.DynamicUser = true; @@ -383,7 +372,7 @@ in system.activationScripts.public-inbox = stringAfter [ "users" ] '' install -m 0755 -o public-inbox -g public-inbox -d ${stateDir} - install -m 0750 -o public-inbox -g public-inbox -d ${inboxesDir} + install -m 0750 -o public-inbox -g public-inbox -d ${stateDir}/inboxes install -m 0700 -o public-inbox -g public-inbox -d ${stateDir}/emergency ${optionalString useSpamAssassin '' @@ -410,12 +399,12 @@ in rm -rf $conf_dir fi - ln -sf ${descriptionFile inbox} ${inboxPath name}/description + ln -sf ${pkgs.writeText "description" inbox.description} ${inboxPath name}/description - if [ -d ${escapeShellArg (gitPath name)} ]; then + if [ -d ${escapeShellArg (inboxPath name)}/all.git ]; then # Config is inherited by each epoch repository, # so just needs to be set for all.git. - ${pkgs.git}/bin/git --git-dir ${gitPath name} \ + ${pkgs.git}/bin/git --git-dir ${inboxPath name}/all.git \ config core.sharedRepository 0640 fi '') cfg.inboxes)} |