From ee4f4fa3e9a84901dc9b660667a816caa04e4920 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 15 Apr 2020 16:15:41 +0000 Subject: 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. --- sys/atuin.nix | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'sys') 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: -- cgit 1.4.1