2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-11-09 21:48:12 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2011-11-09 21:48:12 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
inherit (pkgs) prayer;
|
|
|
|
|
2011-11-09 22:08:50 +01:00
|
|
|
cfg = config.services.prayer;
|
|
|
|
|
2011-11-09 21:48:12 +01: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}"
|
2017-01-29 11:11:01 +01:00
|
|
|
sendmail_path = "/run/wrappers/bin/sendmail"
|
2011-11-09 21:48:12 +01:00
|
|
|
|
2011-11-09 22:08:50 +01:00
|
|
|
use_http_port ${cfg.port}
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
2011-11-09 21:48:12 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
prayerCfg = pkgs.runCommand "prayer.cf" { } ''
|
2012-06-10 16:51:43 +02: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 21:48:12 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.prayer = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2011-11-09 22:08:50 +01:00
|
|
|
Whether to run the prayer webmail http server.
|
2011-11-09 21:48:12 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2011-11-09 22:08:50 +01:00
|
|
|
port = mkOption {
|
|
|
|
default = "2080";
|
2011-11-09 21:48:12 +01:00
|
|
|
description = ''
|
2011-11-09 22:08:50 +01:00
|
|
|
Port the prayer http server is listening to.
|
2011-11-09 21:48:12 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2016-10-23 19:33:41 +02:00
|
|
|
type = types.lines;
|
2011-11-09 21:48:12 +01:00
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.prayer.enable {
|
|
|
|
environment.systemPackages = [ prayer ];
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users = singleton
|
2011-11-09 21:48:12 +01:00
|
|
|
{ name = prayerUser;
|
|
|
|
uid = config.ids.uids.prayer;
|
2012-03-22 11:11:15 +01:00
|
|
|
description = "Prayer daemon user";
|
2011-11-09 21:48:12 +01:00
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups = singleton
|
2011-11-09 21:48:12 +01:00
|
|
|
{ name = prayerGroup;
|
|
|
|
gid = config.ids.gids.prayer;
|
|
|
|
};
|
|
|
|
|
2016-01-06 07:50:18 +01:00
|
|
|
systemd.services.prayer = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig.Type = "forking";
|
|
|
|
preStart = ''
|
|
|
|
mkdir -m 0755 -p ${stateDir}
|
|
|
|
chown ${prayerUser}.${prayerGroup} ${stateDir}
|
|
|
|
'';
|
|
|
|
script = "${prayer}/sbin/prayer --config-file=${prayerCfg}";
|
|
|
|
};
|
2011-11-09 21:48:12 +01:00
|
|
|
};
|
|
|
|
}
|