ssmtp: use services.ssmtp.* options

This PR is part of the networking.* namespace cleanup.

ssmtp used to be configured via `networking.defaultMailServer` which is
sort of misleading since it provides options only for ssmtp. Other
dumb mail relays like nullmailer have always been living under
services.

The intent of this PR is to align ssmtp's options with those of similar
services. Specifically, two renames have been done:

* Rename `networking.defaultMailHost` to `services.ssmtp`.
* Rename `directDelivery` to `enable` because this is what it basically does.
This commit is contained in:
Christian Kauhaus 2019-11-24 16:38:52 +01:00
parent 6127bf9837
commit dd87e9eb4d
3 changed files with 10 additions and 10 deletions

View File

@ -8,18 +8,16 @@
with lib; with lib;
let let
cfg = config.services.ssmtp;
cfg = config.networking.defaultMailServer;
in in
{ {
options = { options = {
networking.defaultMailServer = { services.ssmtp = {
directDelivery = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = ''
@ -29,7 +27,7 @@ in
<command>sendmail</command> or <command>postfix</command> on <command>sendmail</command> or <command>postfix</command> on
your machine, set this option to <literal>true</literal>, and your machine, set this option to <literal>true</literal>, and
set the option set the option
<option>networking.defaultMailServer.hostName</option> to the <option>services.ssmtp.hostName</option> to the
host name of your preferred mail server. host name of your preferred mail server.
''; '';
}; };
@ -129,9 +127,9 @@ in
}; };
config = mkIf cfg.directDelivery { config = mkIf cfg.enable {
networking.defaultMailServer.authPassFile = mkIf (cfg.authPass != "") services.ssmtp.authPassFile = mkIf (cfg.authPass != "")
(mkDefault (toString (pkgs.writeTextFile { (mkDefault (toString (pkgs.writeTextFile {
name = "ssmtp-authpass"; name = "ssmtp-authpass";
text = cfg.authPass; text = cfg.authPass;

View File

@ -11,6 +11,8 @@ with lib;
(mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) (mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "networkmanager" "useDnsmasq" ] [ "networking" "networkmanager" "dns" ]) (mkRenamedOptionModule [ "networking" "networkmanager" "useDnsmasq" ] [ "networking" "networkmanager" "dns" ])
(mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ]) (mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ])
(mkRenamedOptionModule [ "networking" "defaultMailServer" ] [ "services" "ssmtp" ])
(mkRenamedOptionModule [ "services" "ssmtp" "directDelivery" ] [ "services" "ssmtp" "enable" ])
(mkChangedOptionModule [ "services" "printing" "gutenprint" ] [ "services" "printing" "drivers" ] (mkChangedOptionModule [ "services" "printing" "gutenprint" ] [ "services" "printing" "drivers" ]
(config: (config:
let enabled = getAttrFromPath [ "services" "printing" "gutenprint" ] config; let enabled = getAttrFromPath [ "services" "printing" "gutenprint" ] config;

View File

@ -9,8 +9,8 @@ import ./make-test.nix ({ lib, ... }:
{ {
services.mailcatcher.enable = true; services.mailcatcher.enable = true;
networking.defaultMailServer.directDelivery = true; services.ssmtp.enable = true;
networking.defaultMailServer.hostName = "localhost:1025"; services.ssmtp.hostName = "localhost:1025";
environment.systemPackages = [ pkgs.mailutils ]; environment.systemPackages = [ pkgs.mailutils ];
}; };