1 { config, lib, pkgs, ... }:
9 cfg = config.services.prayer;
11 stateDir = "/var/lib/prayer";
13 prayerUser = "prayer";
14 prayerGroup = "prayer";
16 prayerExtraCfg = pkgs.writeText "extraprayer.cf" ''
18 var_prefix = "${stateDir}"
19 prayer_user = "${prayerUser}"
20 prayer_group = "${prayerGroup}"
21 sendmail_path = "/run/wrappers/bin/sendmail"
23 use_http_port ${cfg.port}
28 prayerCfg = pkgs.runCommand "prayer.cf" { preferLocalBuild = true; } ''
29 # We have to remove the http_port 80, or it will start a server there
30 cat ${prayer}/etc/prayer.cf | grep -v http_port > $out
31 cat ${prayerExtraCfg} >> $out
44 enable = mkEnableOption (lib.mdDoc "the prayer webmail http server");
49 description = lib.mdDoc ''
50 Port the prayer http server is listening to.
54 extraConfig = mkOption {
57 description = lib.mdDoc ''
58 Extra configuration. Contents will be added verbatim to the configuration file.
68 config = mkIf config.services.prayer.enable {
69 environment.systemPackages = [ prayer ];
71 users.users.${prayerUser} =
72 { uid = config.ids.uids.prayer;
73 description = "Prayer daemon user";
77 users.groups.${prayerGroup} =
78 { gid = config.ids.gids.prayer; };
80 systemd.services.prayer = {
81 wantedBy = [ "multi-user.target" ];
82 serviceConfig.Type = "forking";
84 mkdir -m 0755 -p ${stateDir}
85 chown ${prayerUser}:${prayerGroup} ${stateDir}
87 script = "${prayer}/sbin/prayer --config-file=${prayerCfg}";