Convert "dovecot"

svn path=/nixos/branches/fix-style/; revision=14393
This commit is contained in:
Marc Weber 2009-03-06 12:27:10 +00:00
parent 32ec389b15
commit a0b0bba762
3 changed files with 85 additions and 63 deletions

View File

@ -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 = { bind = {
enable = mkOption { enable = mkOption {
default = false; default = false;
@ -647,6 +618,7 @@ in
(import ../upstart-jobs/postgresql.nix) (import ../upstart-jobs/postgresql.nix)
(import ../upstart-jobs/openfire.nix) (import ../upstart-jobs/openfire.nix)
(import ../upstart-jobs/postfix.nix) (import ../upstart-jobs/postfix.nix)
(import ../upstart-jobs/dovecot.nix)
# nix # nix
(import ../upstart-jobs/nix.nix) # nix options and daemon (import ../upstart-jobs/nix.nix) # nix options and daemon

View File

@ -131,12 +131,6 @@ let
inherit config; inherit config;
}) })
# Dovecot POP3/IMAP server.
++ optional config.services.dovecot.enable
(import ../upstart-jobs/dovecot.nix {
inherit config pkgs;
})
# ISC BIND domain name server. # ISC BIND domain name server.
++ optional config.services.bind.enable ++ optional config.services.bind.enable
(import ../upstart-jobs/bind.nix { (import ../upstart-jobs/bind.nix {

View File

@ -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 let
startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces"; startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";
@ -54,36 +95,51 @@ let
''; '';
in 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 = '' mkIf config.services.dovecot.enable {
description "Dovecot IMAP/POP3 server"
start on ${startingDependency}/started require = [
stop on never options
];
start script environment = {
${pkgs.coreutils}/bin/mkdir -p /var/run/dovecot /var/run/dovecot/login etc = [{
${pkgs.coreutils}/bin/chown -R ${cfg.user}.${cfg.group} /var/run/dovecot source = pamdFile;
end script 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 = [{ services = {
source = pamdFile; extraJobs = [{
target = "pam.d/dovecot"; 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}
'';
}];
};
} }