about summary refs log tree commit diff
path: root/sys
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-04-15 16:15:41 +0000
committerAlyssa Ross <hi@alyssa.is>2020-04-15 16:41:47 +0000
commitee4f4fa3e9a84901dc9b660667a816caa04e4920 (patch)
tree4eb73491c5af3d3ff4e2e9d8e18ef4d89aed0757 /sys
parent60fc867015ec7c385bceffff03db14546b72a9d7 (diff)
downloadnixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.tar
nixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.tar.gz
nixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.tar.bz2
nixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.tar.lz
nixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.tar.xz
nixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.tar.zst
nixlib-ee4f4fa3e9a84901dc9b660667a816caa04e4920.zip
sys/atuin: fix fastcgi_params overrides
It turns out you can't just selectively override these.  You need to
re-specify all of them every time you want to change any of them.  I
don't want to have to do that, hence the overrideFastcgiParams
function.
Diffstat (limited to 'sys')
-rw-r--r--sys/atuin.nix41
1 files changed, 36 insertions, 5 deletions
diff --git a/sys/atuin.nix b/sys/atuin.nix
index a7678c9765dc..58eede6705a5 100644
--- a/sys/atuin.nix
+++ b/sys/atuin.nix
@@ -159,11 +159,13 @@
           root = "${pkgs.cgit}/cgit";
 
           locations."@cgit".extraConfig = ''
-            fastcgi_param CGIT_CONFIG ${cgitConfig};
-            fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
-            fastcgi_param PATH_INFO $uri;
-            fastcgi_param QUERY_STRING $args;
-            fastcgi_param HTTP_HOST $server_name;
+            ${overrideFastcgiParams {
+              CGIT_CONFIG = cgitConfig;
+              SCRIPT_FILENAME = "$document_root/cgit.cgi";
+              PATH_INFO = "$uri";
+              QUERY_STRING = "$args";
+              HTTP_HOST = "$server_name";
+            }}
 
             fastcgi_pass unix:/run/fcgiwrap.sock;
           '';
@@ -179,6 +181,35 @@
         root-title=git.qyliss.net
         virtual-root=/
       '';
+
+      overrideFastcgiParams = with lib; params: concatStrings (mapAttrsToList (n: v: ''
+        fastcgi_param ${n} ${if v == "" then ''""'' else v};
+      '') ({
+        SCRIPT_FILENAME   = "$document_root$fastcgi_script_name";
+        QUERY_STRING      = "$query_string";
+        REQUEST_METHOD    = "$request_method";
+        CONTENT_TYPE      = "$content_type";
+        CONTENT_LENGTH    = "$content_length";
+
+        SCRIPT_NAME       = "$fastcgi_script_name";
+        REQUEST_URI       = "$request_uri";
+        DOCUMENT_URI      = "$document_uri";
+        DOCUMENT_ROOT     = "$document_root";
+        SERVER_PROTOCOL   = "$server_protocol";
+        REQUEST_SCHEME    = "$scheme";
+        HTTPS             = "$https if_not_empty";
+
+        GATEWAY_INTERFACE = "CGI/1.1";
+        SERVER_SOFTWARE   = "nginx/$nginx_version";
+
+        REMOTE_ADDR       = "$remote_addr";
+        REMOTE_PORT       = "$remote_port";
+        SERVER_ADDR       = "$server_addr";
+        SERVER_PORT       = "$server_port";
+        SERVER_NAME       = "$server_name";
+
+        REDIRECT_STATUS   = "200";
+      } // params));
     in
       lib.mapAttrs (
         _: { forceSSL ? true, enableACME ? true, ... } @ args: