summary refs log tree commit diff
path: root/modules/services/networking/prayer.nix
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2011-11-09 20:48:12 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2011-11-09 20:48:12 +0000
commit578f83eef41d7b5a1a25cb7c167541099c81ecc3 (patch)
treec937eb06aa941895920f855c82d3ba0eeec047bd /modules/services/networking/prayer.nix
parent0302e2cc574e3cc104199fba137a928ce11eeca2 (diff)
downloadnixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.tar
nixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.tar.gz
nixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.tar.bz2
nixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.tar.lz
nixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.tar.xz
nixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.tar.zst
nixpkgs-578f83eef41d7b5a1a25cb7c167541099c81ecc3.zip
Adding a module for the prayer webmail.
svn path=/nixos/trunk/; revision=30361
Diffstat (limited to 'modules/services/networking/prayer.nix')
-rw-r--r--modules/services/networking/prayer.nix104
1 files changed, 104 insertions, 0 deletions
diff --git a/modules/services/networking/prayer.nix b/modules/services/networking/prayer.nix
new file mode 100644
index 00000000000..10130c24049
--- /dev/null
+++ b/modules/services/networking/prayer.nix
@@ -0,0 +1,104 @@
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let
+
+  inherit (pkgs) prayer;
+
+  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"
+
+    ${config.services.prayer.extraConfig}
+  '';
+
+  prayerCfg = pkgs.runCommand "prayer.cf" { } ''
+    cat ${prayer}/etc/prayer.cf ${prayerExtraCfg} > $out
+  '';
+
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.prayer = {
+
+      enable = mkOption {
+        default = false;
+        description = ''
+          Whether to run the machine as a HTTP proxy server.
+        '';
+      };
+
+      listenAddress = mkOption {
+        default = "127.0.0.1:8118";
+        description = ''
+          Address the proxy server is listening to.
+        '';
+      };
+
+      logDir = mkOption {
+        default = "/var/log/prayer" ;
+        description = ''
+          Location for prayer log files.
+        '';
+      };
+
+      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;
+        description = "prayer daemon user";
+        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}";
+      };
+  };
+
+}