From 9dd7891820a9a3e37896bc86f1cc26a8dddbba1d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 23 Nov 2007 17:12:37 +0000 Subject: [PATCH] * Options for configuring the (mail) domain. svn path=/nixos/trunk/; revision=9785 --- etc/default.nix | 9 +++++---- system/options.nix | 16 +++++++++++++++ upstart-jobs/default.nix | 6 +----- upstart-jobs/network-interfaces.nix | 30 +++++++++++++++-------------- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/etc/default.nix b/etc/default.nix index 5d230ff893b1..a43bcf7fe6fc 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -134,10 +134,11 @@ import ../helpers/make-etc.nix { # Configuration for ssmtp. ++ optional config.networking.defaultMailServer.directDelivery { - source = pkgs.writeText "ssmtp.conf" " -mailhub=${config.networking.defaultMailServer.hostName} -UseTLS=${if config.networking.defaultMailServer.useTLS then "YES" else "NO"} -UseSTARTTLS=${if config.networking.defaultMailServer.useSTARTTLS then "YES" else "NO"} + source = let cfg = config.networking.defaultMailServer; in pkgs.writeText "ssmtp.conf" " +mailhub=${cfg.hostName} +${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"; diff --git a/system/options.nix b/system/options.nix index d525136b5a8c..fee70d3311eb 100644 --- a/system/options.nix +++ b/system/options.nix @@ -265,6 +265,14 @@ "; }; + domain = mkOption { + default = ""; + example = "home"; + description = " + The domain. It can be left empty if it is auto-detected through DHCP. + "; + }; + enableIntel2200BGFirmware = mkOption { default = false; description = " @@ -335,6 +343,14 @@ "; }; + domain = mkOption { + default = ""; + example = "example.org"; + description = " + The domain from which mail will appear to be sent. + "; + }; + useTLS = mkOption { default = false; example = true; diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index a4ab27e001fa..85358be096b4 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -65,12 +65,8 @@ let # Network interfaces. (import ../upstart-jobs/network-interfaces.nix { - inherit modprobe; + inherit modprobe config; inherit (pkgs) nettools wirelesstools bash writeText; - nameservers = config.networking.nameservers; - defaultGateway = config.networking.defaultGateway; - interfaces = config.networking.interfaces; - localCommands = config.networking.localCommands; }) # Nix daemon - required for multi-user Nix. diff --git a/upstart-jobs/network-interfaces.nix b/upstart-jobs/network-interfaces.nix index b3f061243107..610ff550536f 100644 --- a/upstart-jobs/network-interfaces.nix +++ b/upstart-jobs/network-interfaces.nix @@ -1,16 +1,15 @@ -{ nettools, modprobe, wirelesstools, bash, writeText -, nameservers, defaultGateway, interfaces -, localCommands -}: +{nettools, modprobe, wirelesstools, bash, writeText, config}: let + cfg = config.networking; + # !!! use XML - names = map (i: i.name) interfaces; - ipAddresses = map (i: if i ? ipAddress then i.ipAddress else "dhcp") interfaces; - subnetMasks = map (i: if i ? subnetMask then i.subnetMask else "default") interfaces; - essids = map (i: if i ? essid then i.essid else "default") interfaces; - wepKeys = map (i: if i ? wepKey then i.wepKey else "nokey") interfaces; + names = map (i: i.name) cfg.interfaces; + ipAddresses = map (i: if i ? ipAddress then i.ipAddress else "dhcp") cfg.interfaces; + subnetMasks = map (i: if i ? subnetMask then i.subnetMask else "default") cfg.interfaces; + essids = map (i: if i ? essid then i.essid else "default") cfg.interfaces; + wepKeys = map (i: if i ? wepKey then i.wepKey else "nokey") cfg.interfaces; in @@ -66,20 +65,23 @@ start script done # Set the nameservers. - if test -n \"${toString nameservers}\"; then + if test -n \"${toString cfg.nameservers}\"; then rm -f /etc/resolv.conf - for i in ${toString nameservers}; do + if test -n \"${cfg.domain}\"; then + echo \"domain ${cfg.domain}\" >> /etc/resolv.conf + fi + for i in ${toString cfg.nameservers}; do echo \"nameserver $i\" >> /etc/resolv.conf done fi # Set the default gateway. - if test -n \"${defaultGateway}\"; then - ${nettools}/sbin/route add default gw \"${defaultGateway}\" || true + if test -n \"${cfg.defaultGateway}\"; then + ${nettools}/sbin/route add default gw \"${cfg.defaultGateway}\" || true fi # Run any user-specified commands. - ${bash}/bin/sh ${writeText "local-net-cmds" localCommands} || true + ${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true end script