2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-11-09 20:48:12 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2011-11-09 20:48:12 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
inherit (pkgs) prayer;
|
|
|
|
|
2011-11-09 21:08:50 +00:00
|
|
|
cfg = config.services.prayer;
|
|
|
|
|
2011-11-09 20:48:12 +00:00
|
|
|
stateDir = "/var/lib/prayer";
|
|
|
|
|
|
|
|
prayerUser = "prayer";
|
|
|
|
prayerGroup = "prayer";
|
|
|
|
|
|
|
|
prayerExtraCfg = pkgs.writeText "extraprayer.cf" ''
|
|
|
|
prefix = "${prayer}"
|
|
|
|
var_prefix = "${stateDir}"
|
|
|
|
prayer_user = "${prayerUser}"
|
|
|
|
prayer_group = "${prayerGroup}"
|
|
|
|
sendmail_path = "/var/setuid-wrappers/sendmail"
|
|
|
|
|
2011-11-09 21:08:50 +00:00
|
|
|
use_http_port ${cfg.port}
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
2011-11-09 20:48:12 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
prayerCfg = pkgs.runCommand "prayer.cf" { } ''
|
2012-06-10 14:51:43 +00:00
|
|
|
# We have to remove the http_port 80, or it will start a server there
|
|
|
|
cat ${prayer}/etc/prayer.cf | grep -v http_port > $out
|
|
|
|
cat ${prayerExtraCfg} >> $out
|
2011-11-09 20:48:12 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.prayer = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2011-11-09 21:08:50 +00:00
|
|
|
Whether to run the prayer webmail http server.
|
2011-11-09 20:48:12 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2011-11-09 21:08:50 +00:00
|
|
|
port = mkOption {
|
|
|
|
default = "2080";
|
2011-11-09 20:48:12 +00:00
|
|
|
description = ''
|
2011-11-09 21:08:50 +00:00
|
|
|
Port the prayer http server is listening to.
|
2011-11-09 20:48:12 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.prayer.enable {
|
|
|
|
environment.systemPackages = [ prayer ];
|
|
|
|
|
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = prayerUser;
|
|
|
|
uid = config.ids.uids.prayer;
|
2012-03-22 10:11:15 +00:00
|
|
|
description = "Prayer daemon user";
|
2011-11-09 20:48:12 +00:00
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = prayerGroup;
|
|
|
|
gid = config.ids.gids.prayer;
|
|
|
|
};
|
|
|
|
|
|
|
|
jobs.prayer =
|
|
|
|
{ name = "prayer";
|
|
|
|
|
|
|
|
startOn = "startup";
|
|
|
|
|
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p ${stateDir}
|
|
|
|
chown ${prayerUser}.${prayerGroup} ${stateDir}
|
|
|
|
'';
|
|
|
|
|
|
|
|
daemonType = "daemon";
|
|
|
|
|
|
|
|
exec = "${prayer}/sbin/prayer --config-file=${prayerCfg}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|