about summary refs log tree commit diff
path: root/modules/git
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/default.nix63
1 files changed, 45 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 "";
+              };
+            };
         };
       }
     ))

Consider giving Nix/NixOS a try! <3