forked from mirrors/nixpkgs
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
136 lines
3.5 KiB
Nix
136 lines
3.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.opensmtpd;
|
|
conf = pkgs.writeText "smtpd.conf" cfg.serverConfiguration;
|
|
args = concatStringsSep " " cfg.extraServerArgs;
|
|
|
|
sendmail = pkgs.runCommand "opensmtpd-sendmail" { preferLocalBuild = true; } ''
|
|
mkdir -p $out/bin
|
|
ln -s ${cfg.package}/sbin/smtpctl $out/bin/sendmail
|
|
'';
|
|
|
|
in {
|
|
|
|
###### interface
|
|
|
|
imports = [
|
|
(mkRenamedOptionModule [ "services" "opensmtpd" "addSendmailToSystemPath" ] [ "services" "opensmtpd" "setSendmail" ])
|
|
];
|
|
|
|
options = {
|
|
|
|
services.opensmtpd = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc "Whether to enable the OpenSMTPD server.";
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.opensmtpd;
|
|
defaultText = literalExpression "pkgs.opensmtpd";
|
|
description = lib.mdDoc "The OpenSMTPD package to use.";
|
|
};
|
|
|
|
setSendmail = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = lib.mdDoc "Whether to set the system sendmail to OpenSMTPD's.";
|
|
};
|
|
|
|
extraServerArgs = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [ "-v" "-P mta" ];
|
|
description = lib.mdDoc ''
|
|
Extra command line arguments provided when the smtpd process
|
|
is started.
|
|
'';
|
|
};
|
|
|
|
serverConfiguration = mkOption {
|
|
type = types.lines;
|
|
example = ''
|
|
listen on lo
|
|
accept for any deliver to lmtp localhost:24
|
|
'';
|
|
description = lib.mdDoc ''
|
|
The contents of the smtpd.conf configuration file. See the
|
|
OpenSMTPD documentation for syntax information.
|
|
'';
|
|
};
|
|
|
|
procPackages = mkOption {
|
|
type = types.listOf types.package;
|
|
default = [];
|
|
description = lib.mdDoc ''
|
|
Packages to search for filters, tables, queues, and schedulers.
|
|
|
|
Add OpenSMTPD-extras here if you want to use the filters, etc. from
|
|
that package.
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable rec {
|
|
users.groups = {
|
|
smtpd.gid = config.ids.gids.smtpd;
|
|
smtpq.gid = config.ids.gids.smtpq;
|
|
};
|
|
|
|
users.users = {
|
|
smtpd = {
|
|
description = "OpenSMTPD process user";
|
|
uid = config.ids.uids.smtpd;
|
|
group = "smtpd";
|
|
};
|
|
smtpq = {
|
|
description = "OpenSMTPD queue user";
|
|
uid = config.ids.uids.smtpq;
|
|
group = "smtpq";
|
|
};
|
|
};
|
|
|
|
security.wrappers.smtpctl = {
|
|
owner = "root";
|
|
group = "smtpq";
|
|
setuid = false;
|
|
setgid = true;
|
|
source = "${cfg.package}/bin/smtpctl";
|
|
};
|
|
|
|
services.mail.sendmailSetuidWrapper = mkIf cfg.setSendmail
|
|
(security.wrappers.smtpctl // { program = "sendmail"; });
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d /var/spool/smtpd 711 root - - -"
|
|
"d /var/spool/smtpd/offline 770 root smtpq - -"
|
|
"d /var/spool/smtpd/purge 700 smtpq root - -"
|
|
];
|
|
|
|
systemd.services.opensmtpd = let
|
|
procEnv = pkgs.buildEnv {
|
|
name = "opensmtpd-procs";
|
|
paths = [ cfg.package ] ++ cfg.procPackages;
|
|
pathsToLink = [ "/libexec/opensmtpd" ];
|
|
};
|
|
in {
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
serviceConfig.ExecStart = "${cfg.package}/sbin/smtpd -d -f ${conf} ${args}";
|
|
environment.OPENSMTPD_PROC_PATH = "${procEnv}/libexec/opensmtpd";
|
|
};
|
|
};
|
|
}
|