about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/mail/public-inbox.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/mail/public-inbox.nix')
-rw-r--r--nixpkgs/nixos/modules/services/mail/public-inbox.nix36
1 files changed, 26 insertions, 10 deletions
diff --git a/nixpkgs/nixos/modules/services/mail/public-inbox.nix b/nixpkgs/nixos/modules/services/mail/public-inbox.nix
index 9bc5cf17a7f5..b13a54a0e2d1 100644
--- a/nixpkgs/nixos/modules/services/mail/public-inbox.nix
+++ b/nixpkgs/nixos/modules/services/mail/public-inbox.nix
@@ -67,11 +67,25 @@ let
     cp $forwardPath $out/.forward
   '';
 
-  psgi = pkgs.substituteAll {
-    src = ./public-inbox.psgi;
-    perl = "${cfg.package.fullperl}/bin/perl";
-    path = cfg.http.mount;
-  };
+  psgi = pkgs.writeText "public-inbox.psgi" ''
+    #!${cfg.package.fullperl} -w
+    # Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
+    # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
+    use strict;
+    use PublicInbox::WWW;
+    use Plack::Builder;
+
+    my $www = PublicInbox::WWW->new;
+    $www->preload;
+
+    builder {
+      enable 'Head';
+      enable 'ReverseProxy';
+      ${concatMapStrings (path: ''
+      mount q(${path}) => sub { $www->call(@_); };
+      '') cfg.http.mounts}
+    }
+  '';
 
   descriptionFile = { description, ... }:
     pkgs.writeText "description" description;
@@ -206,12 +220,14 @@ in
       };
 
       http = {
-        mount = mkOption {
-          type = types.str;
-          default = "/";
-          example = "/lists/archives";
+        mounts = mkOption {
+          type = with types; listOf str;
+          default = [ "/" ];
+          example = [ "/lists/archives" ];
           description = ''
-            Path components to prepend to public-inbox HTTP endpoints
+            Root paths or URLs that public-inbox will be served on.
+            If domain parts are present, only requests to those
+            domains will be accepted.
           '';
         };