2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-11-09 20:48:12 +00:00
|
|
|
|
2014-04-14 15:26:48 +01: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}"
|
2017-01-29 10:11:01 +00:00
|
|
|
sendmail_path = "/run/wrappers/bin/sendmail"
|
2011-11-09 20:48:12 +00:00
|
|
|
|
2011-11-09 21:08:50 +00:00
|
|
|
use_http_port ${cfg.port}
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
2011-11-09 20:48:12 +00:00
|
|
|
'';
|
|
|
|
|
2018-11-08 10:59:03 +00:00
|
|
|
prayerCfg = pkgs.runCommand "prayer.cf" { preferLocalBuild = true; } ''
|
2012-06-10 15:51:43 +01: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 = {
|
|
|
|
|
2020-04-20 19:05:26 +01:00
|
|
|
enable = mkEnableOption "the prayer webmail http server";
|
2011-11-09 20:48:12 +00:00
|
|
|
|
2011-11-09 21:08:50 +00:00
|
|
|
port = mkOption {
|
2021-01-31 11:01:41 +00:00
|
|
|
default = 2080;
|
|
|
|
type = types.port;
|
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 {
|
2016-10-23 18:33:41 +01:00
|
|
|
type = types.lines;
|
2011-11-09 20:48:12 +00:00
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.prayer.enable {
|
|
|
|
environment.systemPackages = [ prayer ];
|
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
users.users.${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;
|
|
|
|
};
|
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
users.groups.${prayerGroup} =
|
|
|
|
{ gid = config.ids.gids.prayer; };
|
2011-11-09 20:48:12 +00:00
|
|
|
|
2016-01-06 06:50:18 +00: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 20:48:12 +00:00
|
|
|
};
|
|
|
|
}
|