about summary refs log tree commit diff
path: root/git.nix
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-03-21 21:37:53 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2023-03-21 21:37:53 +0900
commitb05541183af2c64014e9c22b398db1504414efc5 (patch)
treec7d8e26d35da63eb40d7a353e0a5fdda4e4b21ca /git.nix
parentf14b484196e09e8c4596c03cd53320d0965210ed (diff)
downloadnixos-conf-b05541183af2c64014e9c22b398db1504414efc5.tar.gz
Set up laminar
Diffstat (limited to 'git.nix')
-rw-r--r--git.nix72
1 files changed, 46 insertions, 26 deletions
diff --git a/git.nix b/git.nix
index 152de98..99fb287 100644
--- a/git.nix
+++ b/git.nix
@@ -19,35 +19,55 @@
 { config, lib, pkgs, ... }:
 let inherit (config.networking) domain;
 in {
-  services = {
-    lighttpd = {
-      cgit = {
-        configText = let
-          httpsClone = "https://trong.${domain}/$CGIT_REPO_URL";
-          scanPath = "/var/lib/git";
-          sshClone = "ssh://${domain}:2211${scanPath}/$CGIT_REPO_URL";
-        in ''
-          about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh
-          source-filter=${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py
+  services = let
+    cgitrc = pkgs.writeText "cgitrc" ''
+      about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh
+      css=/style.css
+      favicon=/favicon.ico
+      logo=/cgit.png
+      source-filter=${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py
+      virtual-root=/
 
-          clone-url=${httpsClone} ${sshClone}
-          enable-blame=1
-          enable-git-config=1
-          readme=:README.md
-          snapshots=tar.gz tar.zst
-          scan-path=${scanPath}
-        '';
-        enable = true;
-        subdir = "";
-      };
-      enable = true;
-      port = 9418;
-    };
+      clone-url=${httpsClone} ${sshClone}
+      enable-blame=1
+      enable-git-config=1
+      enable-index-links=1
+      enable-index-owner=0
+      readme=:README.md
+      snapshots=tar.gz tar.zst
+      scan-path=${scanPath}
+    '';
+    css = builtins.readFile "${pkgs.cgit}/cgit/cgit.css" + ''
 
-    nginx."trong.${domain}" = let port = config.services.lighttpd.port;
-    in {
+      div#cgit {
+          font-size: initial;
+      }
+    '';
+    httpsClone = "https://trong.${domain}/$CGIT_REPO_URL";
+    scanPath = "/var/lib/git";
+    sshClone = "ssh://${domain}:2211${scanPath}/$CGIT_REPO_URL";
+  in {
+    fcgiwrap.enable = true;
+    nginx.virtualHosts."trong.${domain}" = {
       enableACME = true;
       forceSSL = true;
-      locations."/".proxyPass = "http://127.0.0.1:${toString port}";
+      locations = {
+        "/" = {
+          root = "${pkgs.cgit}/cgit/";
+          tryFiles = "$uri @cgit";
+        };
+        "~ ^/(cgit.png|favicon.ico|robots.txt)$".alias = "${pkgs.cgit}/cgit/$1";
+        "= /style.css".alias = builtins.toFile "style.css" css;
+        "@cgit".extraConfig = ''
+          include ${pkgs.nginx}/conf/fastcgi_params;
+          fastcgi_param CGIT_CONFIG ${cgitrc};
+          fastcgi_param HTTP_HOST $server_name;
+          fastcgi_param PATH_INFO $uri;
+          fastcgi_param QUERY_STRING $args;
+          fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
+          fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
+        '';
+      };
     };
+  };
 }