From a0b0bba7626a28ebc23cd3158aff65d19b37c096 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 6 Mar 2009 12:27:10 +0000 Subject: [PATCH] Convert "dovecot" svn path=/nixos/branches/fix-style/; revision=14393 --- system/options.nix | 30 +---------- upstart-jobs/default.nix | 6 --- upstart-jobs/dovecot.nix | 112 +++++++++++++++++++++++++++++---------- 3 files changed, 85 insertions(+), 63 deletions(-) diff --git a/system/options.nix b/system/options.nix index d2e1197330a..99904c7b7a0 100644 --- a/system/options.nix +++ b/system/options.nix @@ -479,35 +479,6 @@ in }; - dovecot = { - enable = mkOption { - default = false; - description = "Whether to enable dovecot POP3/IMAP server."; - }; - - user = mkOption { - default = "dovecot"; - description = "dovecot user name"; - }; - group = mkOption { - default = "dovecot"; - description = "dovecot group name"; - }; - - sslServerCert = mkOption { - default = ""; - description = "Server certificate"; - }; - sslCACert = mkOption { - default = ""; - description = "CA certificate used by server certificate"; - }; - sslServerKey = mkOption { - default = ""; - description = "Server key"; - }; - }; - bind = { enable = mkOption { default = false; @@ -647,6 +618,7 @@ in (import ../upstart-jobs/postgresql.nix) (import ../upstart-jobs/openfire.nix) (import ../upstart-jobs/postfix.nix) + (import ../upstart-jobs/dovecot.nix) # nix (import ../upstart-jobs/nix.nix) # nix options and daemon diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index ff8b8a9e9ba..a11ec89acb8 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -131,12 +131,6 @@ let inherit config; }) - # Dovecot POP3/IMAP server. - ++ optional config.services.dovecot.enable - (import ../upstart-jobs/dovecot.nix { - inherit config pkgs; - }) - # ISC BIND domain name server. ++ optional config.services.bind.enable (import ../upstart-jobs/bind.nix { diff --git a/upstart-jobs/dovecot.nix b/upstart-jobs/dovecot.nix index d7d74261e13..8a70a5462d1 100644 --- a/upstart-jobs/dovecot.nix +++ b/upstart-jobs/dovecot.nix @@ -1,4 +1,45 @@ -{config, pkgs}: +{pkgs, config, ...}: + +###### interface +let + inherit (pkgs.lib) mkOption mkIf; + + options = { + services = { + dovecot = { + enable = mkOption { + default = false; + description = "Whether to enable dovecot POP3/IMAP server."; + }; + + user = mkOption { + default = "dovecot"; + description = "dovecot user name"; + }; + group = mkOption { + default = "dovecot"; + description = "dovecot group name"; + }; + + sslServerCert = mkOption { + default = ""; + description = "Server certificate"; + }; + sslCACert = mkOption { + default = ""; + description = "CA certificate used by server certificate"; + }; + sslServerKey = mkOption { + default = ""; + description = "Server key"; + }; + }; + }; + }; +in + +###### implementation + let startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces"; @@ -54,36 +95,51 @@ let ''; in -{ - name = "dovecot"; - users = [{ - name = cfg.user; - uid = idList.uids.dovecot; - description = "Dovecot user"; - group = cfg.group; - }]; - groups = [{ - name = cfg.group; - gid = idList.gids.dovecot; - }]; - job = '' - description "Dovecot IMAP/POP3 server" +mkIf config.services.dovecot.enable { - start on ${startingDependency}/started - stop on never + require = [ + options + ]; - start script - ${pkgs.coreutils}/bin/mkdir -p /var/run/dovecot /var/run/dovecot/login - ${pkgs.coreutils}/bin/chown -R ${cfg.user}.${cfg.group} /var/run/dovecot - end script + environment = { + etc = [{ + source = pamdFile; + target = "pam.d/dovecot"; + }]; + }; - respawn ${pkgs.dovecot}/sbin/dovecot -F -c ${confFile} - ''; + users = { + extraUsers = [{ + name = cfg.user; + uid = idList.uids.dovecot; + description = "Dovecot user"; + group = cfg.group; + }]; + extraGroups = [{ + name = cfg.group; + gid = idList.gids.dovecot; + }]; + }; - extraEtc = [{ - source = pamdFile; - target = "pam.d/dovecot"; - }]; + services = { + extraJobs = [{ + name = "dovecot"; + + job = '' + description "Dovecot IMAP/POP3 server" + + start on ${startingDependency}/started + stop on never + + start script + ${pkgs.coreutils}/bin/mkdir -p /var/run/dovecot /var/run/dovecot/login + ${pkgs.coreutils}/bin/chown -R ${cfg.user}.${cfg.group} /var/run/dovecot + end script + + respawn ${pkgs.dovecot}/sbin/dovecot -F -c ${confFile} + ''; + + }]; + }; } -