diff --git a/etc/default.nix b/etc/default.nix index 7cffdf082aad..6b15245e4cb1 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -134,33 +134,8 @@ let target = "skel/.bashrc"; } - { # SSH configuration. Slight duplication of the sshd_config - # generation in the sshd service. - source = pkgs.writeText "ssh_config" '' - ${if config.services.sshd.forwardX11 then '' - ForwardX11 yes - XAuthLocation ${pkgs.xorg.xauth}/bin/xauth - '' else '' - ForwardX11 no - ''} - ''; - target = "ssh/ssh_config"; - } ] - # Configuration for ssmtp. - ++ optional config.networking.defaultMailServer.directDelivery { - source = let cfg = config.networking.defaultMailServer; in pkgs.writeText "ssmtp.conf" '' - MailHub=${cfg.hostName} - FromLineOverride=YES - ${if cfg.domain != "" then "rewriteDomain=${cfg.domain}" else ""} - UseTLS=${if cfg.useTLS then "YES" else "NO"} - UseSTARTTLS=${if cfg.useSTARTTLS then "YES" else "NO"} - #Debug=YES - ''; - target = "ssmtp/ssmtp.conf"; - } - # A bunch of PAM configuration files for various programs. ++ (map (program: diff --git a/modules/config/system-path.nix b/modules/config/system-path.nix index 41903297252a..c5708a530624 100644 --- a/modules/config/system-path.nix +++ b/modules/config/system-path.nix @@ -71,7 +71,6 @@ let (import ../../helpers/info-wrapper.nix {inherit (pkgs) bash texinfo writeScriptBin;}) ] ++ pkgs.lib.optional config.services.bitlbee.enable pkgs.bitlbee - ++ pkgs.lib.optional config.networking.defaultMailServer.directDelivery pkgs.ssmtp ++ config.environment.extraPackages ++ pkgs.lib.optional config.fonts.enableFontDir config.system.build.x11Fonts diff --git a/modules/module-list.nix b/modules/module-list.nix index 19fc5d10fbfc..96e276df98d2 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -1,4 +1,4 @@ -[ # This file have been generated by gen-module-list.sh +[ # This file has been generated by gen-module-list.sh ./config/fonts.nix ./config/i18n.nix ./config/nsswitch.nix @@ -8,6 +8,8 @@ ./config/users-groups.nix ./installer/grub/grub.nix ./legacy.nix + ./programs/ssh.nix + ./programs/ssmtp.nix ./security/setuid-wrappers.nix ./security/sudo.nix ./services/audio/alsa.nix diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix new file mode 100644 index 000000000000..c325a4bea34d --- /dev/null +++ b/modules/programs/ssh.nix @@ -0,0 +1,20 @@ +# Global configuration for the SSH client. + +{config, pkgs, ...}: + +{ + environment.etc = + [ { # SSH configuration. Slight duplication of the sshd_config + # generation in the sshd service. + source = pkgs.writeText "ssh_config" '' + ${if config.services.sshd.forwardX11 then '' + ForwardX11 yes + XAuthLocation ${pkgs.xorg.xauth}/bin/xauth + '' else '' + ForwardX11 no + ''} + ''; + target = "ssh/ssh_config"; + } + ]; +} diff --git a/modules/programs/ssmtp.nix b/modules/programs/ssmtp.nix new file mode 100644 index 000000000000..a0ecf763528e --- /dev/null +++ b/modules/programs/ssmtp.nix @@ -0,0 +1,91 @@ +# Configuration for `ssmtp', a trivial mail transfer agent that can +# replace sendmail/postfix on simple systems. It delivers email +# directly to an SMTP server defined in its configuration file, wihout +# queueing mail locally. + +{config, pkgs, ...}: + +with pkgs.lib; + +let + + options = { + + networking.defaultMailServer = { + + directDelivery = mkOption { + default = false; + example = true; + description = " + Use the trivial Mail Transfer Agent (MTA) + ssmtp package to allow programs to send + e-mail. If you don't want to run a ``real'' MTA like + sendmail or postfix on + your machine, set this option to true, and + set the option + to the + host name of your preferred mail server. + "; + }; + + hostName = mkOption { + example = "mail.example.org"; + description = " + The host name of the default mail server to use to deliver + e-mail. + "; + }; + + domain = mkOption { + default = ""; + example = "example.org"; + description = " + The domain from which mail will appear to be sent. + "; + }; + + useTLS = mkOption { + default = false; + example = true; + description = " + Whether TLS should be used to connect to the default mail + server. + "; + }; + + useSTARTTLS = mkOption { + default = false; + example = true; + description = " + Whether the STARTTLS should be used to connect to the default + mail server. (This is needed for TLS-capable mail servers + running on the default SMTP port 25.) + "; + }; + + }; + + }; + + cfg = config.networking.defaultMailServer; + +in + +mkIf cfg.directDelivery { + require = [options]; + + environment.etc = + [ { source = pkgs.writeText "ssmtp.conf" '' + MailHub=${cfg.hostName} + FromLineOverride=YES + ${if cfg.domain != "" then "rewriteDomain=${cfg.domain}" else ""} + UseTLS=${if cfg.useTLS then "YES" else "NO"} + UseSTARTTLS=${if cfg.useSTARTTLS then "YES" else "NO"} + #Debug=YES + ''; + target = "ssmtp/ssmtp.conf"; + } + ]; + + environment.extraPackages = [pkgs.ssmtp]; +} diff --git a/system/options.nix b/system/options.nix index f070d8674164..8e3308174e73 100644 --- a/system/options.nix +++ b/system/options.nix @@ -85,60 +85,6 @@ in "; }; - defaultMailServer = { - - directDelivery = mkOption { - default = false; - example = true; - description = " - Use the trivial Mail Transfer Agent (MTA) - ssmtp package to allow programs to send - e-mail. If you don't want to run a ``real'' MTA like - sendmail or postfix on - your machine, set this option to true, and - set the option - to the - host name of your preferred mail server. - "; - }; - - hostName = mkOption { - example = "mail.example.org"; - description = " - The host name of the default mail server to use to deliver - e-mail. - "; - }; - - domain = mkOption { - default = ""; - example = "example.org"; - description = " - The domain from which mail will appear to be sent. - "; - }; - - useTLS = mkOption { - default = false; - example = true; - description = " - Whether TLS should be used to connect to the default mail - server. - "; - }; - - useSTARTTLS = mkOption { - default = false; - example = true; - description = " - Whether the STARTTLS should be used to connect to the default - mail server. (This is needed for TLS-capable mail servers - running on the default SMTP port 25.) - "; - }; - - }; - };