about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-07-29 13:21:02 +0300
committerAzat Bahawi <azat@bahawi.net>2024-07-29 13:21:02 +0300
commit40e1c1da0ab384440043424a1988f8d7f57cf879 (patch)
tree83bfdd90603d73770c0e5e772ccf617f8e15ecec /modules
parent2024-07-29 (diff)
2024-07-29
Diffstat (limited to 'modules')
-rw-r--r--modules/git/default.nix63
-rw-r--r--modules/nginx.nix1
2 files changed, 46 insertions, 18 deletions
diff --git a/modules/git/default.nix b/modules/git/default.nix
index 909bc2b..eb0021d 100644
--- a/modules/git/default.nix
+++ b/modules/git/default.nix
@@ -195,21 +195,18 @@ in
         # FIXME Plausible, go-import, custom favicon, etc.
         nixfiles.modules.nginx = {
           enable = true;
-          virtualHosts.${domain}.locations = {
-            "/".extraConfig = mkOrder 5000 ''
-              ${libNginx.config.appendHead [
-                ''<meta name="go-import" content="$host$uri git https://$host$uri">''
-                (libPlausible.htmlPlausibleScript { inherit (cfg.server) domain; })
-              ]}
-            '';
-          };
+          virtualHosts.${domain}.locations = { };
         };
 
         services = {
           cgit.${domain} = {
             enable = true;
+
+            # We make gitolite repos readable by the common group.
             group = "git";
+
             scanPath = "${config.services.gitolite.dataDir}/repositories";
+
             settings = {
               root-title = "cgit";
               root-desc = "https://github.com/azahi";
@@ -223,17 +220,9 @@ in
               enable-git-config = true;
               enable-gitweb-owner = true;
               remove-suffix = true;
+
+              logo = "/logo.gif";
             };
-            extraConfig = ''
-              readme=:README
-              readme=:README.md
-              readme=:README.org
-              readme=:README.txt
-              readme=:readme
-              readme=:readme.md
-              readme=:readme.org
-              readme=:readme.txt
-            '';
           };
 
           gitolite = {
@@ -252,6 +241,44 @@ in
               $RC{GIT_CONFIG_KEYS} = '.*';
             '';
           };
+
+          nginx.virtualHosts.${domain}.locations =
+            let
+              extraHead = ''
+                ${libNginx.config.appendHead [
+                  ''<meta name="go-import" content="$host$uri git https://$host$uri">''
+                  (libPlausible.htmlPlausibleScript { inherit (cfg.server) domain; })
+                ]}
+              '';
+            in
+            {
+              "/" = {
+                extraConfig = mkBefore extraHead;
+                fastcgiParams.HTTP_ACCEPT_ENCODING = "";
+              };
+              "~ /.+/(info/refs|git-upload-pack)" = {
+                extraConfig = mkBefore extraHead;
+                fastcgiParams.HTTP_ACCEPT_ENCODING = "";
+              };
+              "= /logo.gif".alias = "${./logo.gif}";
+              "= /favicon.ico" = {
+                alias = "${./favicon.ico}";
+                extraConfig = mkForce "";
+              };
+              "= /cgit.css" = {
+                alias = pkgs.writeText "cgit.css" ''
+                  ${readFile "${package}/cgit/cgit.css"}
+                  div#cgit {
+                    font-family: ${
+                      concatMapStringsSep ", " (f: ''"${f}"'') config.fonts.fontconfig.defaultFonts.monospace
+                    }, monospace !important;
+                    -moz-tab-size: 2 !important;
+                    tab-size: 2 !important;
+                  }
+                '';
+                extraConfig = mkForce "";
+              };
+            };
         };
       }
     ))
diff --git a/modules/nginx.nix b/modules/nginx.nix
index b912e22..2ac6d1b 100644
--- a/modules/nginx.nix
+++ b/modules/nginx.nix
@@ -34,6 +34,7 @@ in
         }
         access_log off;
       '';
+      # FIXME This stopped working.
       appendHead = text: ''
         sub_filter '</head>' '${lib.concatStrings text}</head>';
         sub_filter_once on;

Consider giving Nix/NixOS a try! <3