about summary refs log tree commit diff
path: root/modules/nixos/git
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos/git')
-rw-r--r--modules/nixos/git/default.nix152
1 files changed, 79 insertions, 73 deletions
diff --git a/modules/nixos/git/default.nix b/modules/nixos/git/default.nix
index cbeb48a..34ca200 100644
--- a/modules/nixos/git/default.nix
+++ b/modules/nixos/git/default.nix
@@ -6,9 +6,11 @@
   pkgs,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.git;
-in {
+in
+{
   options.nixfiles.modules.git.server = {
     enable = mkEnableOption "Git server";
 
@@ -26,59 +28,59 @@ in {
   };
 
   config = mkIf cfg.server.enable {
-    ark.directories = [
-      config.services.gitolite.dataDir
-    ];
+    ark.directories = [ config.services.gitolite.dataDir ];
 
     nixfiles.modules.nginx = {
       enable = true;
       virtualHosts.${cfg.server.domain} = {
         locations = {
-          "/".extraConfig = let
-            cgitrc = pkgs.writeText "cgitrc" ''
-              root-title=github sux (⩺_⩹)
-              root-desc=https://github.com/azahi
+          "/".extraConfig =
+            let
+              cgitrc = pkgs.writeText "cgitrc" ''
+                root-title=github sux (⩺_⩹)
+                root-desc=https://github.com/azahi
 
-              clone-url=https://${cfg.server.domain}/$CGIT_REPO_URL
+                clone-url=https://${cfg.server.domain}/$CGIT_REPO_URL
 
-              logo=/cgit-custom-logo.gif
-              favicon=/cgit-custom-favicon.gif
-              css=/cgit-custom-style.css
+                logo=/cgit-custom-logo.gif
+                favicon=/cgit-custom-favicon.gif
+                css=/cgit-custom-style.css
 
-              about-filter=${cfg.server.package}/lib/cgit/filters/about-formatting.sh
-              source-filter=${cfg.server.package}/lib/cgit/filters/syntax-highlighting.py
-              commit-filter=${cfg.server.package}/lib/cgit/filters/commit-links.sh
+                about-filter=${cfg.server.package}/lib/cgit/filters/about-formatting.sh
+                source-filter=${cfg.server.package}/lib/cgit/filters/syntax-highlighting.py
+                commit-filter=${cfg.server.package}/lib/cgit/filters/commit-links.sh
 
-              enable-git-config=1
-              enable-gitweb-owner=1
-              remove-suffix=1
+                enable-git-config=1
+                enable-gitweb-owner=1
+                remove-suffix=1
 
-              readme=:README
-              readme=:README.md
-              readme=:README.org
-              readme=:README.txt
-              readme=:readme
-              readme=:readme.md
-              readme=:readme.org
-              readme=:readme.txt
+                readme=:README
+                readme=:README.md
+                readme=:README.org
+                readme=:README.txt
+                readme=:readme
+                readme=:readme.md
+                readme=:readme.org
+                readme=:readme.txt
 
-              scan-path=${config.services.gitolite.dataDir}/repositories
-            '';
-          in ''
-            include ${config.services.nginx.package}/conf/fastcgi_params;
-            fastcgi_split_path_info ^(/?)(.+)$;
-            fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
-            fastcgi_param SCRIPT_FILENAME ${cfg.server.package}/cgit/cgit.cgi;
-            fastcgi_param CGIT_CONFIG ${cgitrc};
-            fastcgi_param PATH_INFO $uri;
-            fastcgi_param QUERY_STRING $args;
-            fastcgi_param HTTP_HOST $server_name;
+                scan-path=${config.services.gitolite.dataDir}/repositories
+              '';
+            in
+            ''
+              include ${config.services.nginx.package}/conf/fastcgi_params;
+              fastcgi_split_path_info ^(/?)(.+)$;
+              fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
+              fastcgi_param SCRIPT_FILENAME ${cfg.server.package}/cgit/cgit.cgi;
+              fastcgi_param CGIT_CONFIG ${cgitrc};
+              fastcgi_param PATH_INFO $uri;
+              fastcgi_param QUERY_STRING $args;
+              fastcgi_param HTTP_HOST $server_name;
 
-            ${libNginx.config.appendHead [
-              ''<meta name="go-import" content="$host$uri git https://$host$uri">''
-              (libPlausible.htmlPlausibleScript {inherit (cfg.server) domain;})
-            ]}
-          '';
+              ${libNginx.config.appendHead [
+                ''<meta name="go-import" content="$host$uri git https://$host$uri">''
+                (libPlausible.htmlPlausibleScript { inherit (cfg.server) domain; })
+              ]}
+            '';
           "~* ^.+(cgit.css|robots.txt)$".extraConfig = ''
             root ${cfg.server.package}/cgit;
           '';
@@ -88,43 +90,47 @@ in {
           "~* ^.+cgit-custom-favicon.gif$".extraConfig = ''
             alias ${./favicon.ico};
           '';
-          "~* ^.+cgit-custom-style.css$".extraConfig = let
-            css = pkgs.writeText "custom.css" ''
-              @import url("cgit.css");
+          "~* ^.+cgit-custom-style.css$".extraConfig =
+            let
+              css = pkgs.writeText "custom.css" ''
+                @import url("cgit.css");
 
-              div#cgit {
-                font-family: monospace;
-                -moz-tab-size: 4;
-                tab-size: 4;
-              }
+                div#cgit {
+                  font-family: monospace;
+                  -moz-tab-size: 4;
+                  tab-size: 4;
+                }
+              '';
+            in
+            ''
+              alias ${css};
             '';
-          in ''
-            alias ${css};
-          '';
         };
       };
     };
 
-    services = let
-      user = "git";
-      group = "git";
-    in {
-      gitolite = {
-        enable = true;
-        inherit user group;
-        adminPubkey = my.ssh.key;
-        extraGitoliteRc = ''
-          # This allows hiding repositories via "cgit.ignore"[1].
-          #
-          # [1]: https://www.omarpolo.com/post/cgit-gitolite.html
-          $RC{GIT_CONFIG_KEYS} = '.*';
-        '';
-      };
+    services =
+      let
+        user = "git";
+        group = "git";
+      in
+      {
+        gitolite = {
+          enable = true;
+          inherit user group;
+          adminPubkey = my.ssh.key;
+          extraGitoliteRc = ''
+            # This allows hiding repositories via "cgit.ignore"[1].
+            #
+            # [1]: https://www.omarpolo.com/post/cgit-gitolite.html
+            $RC{GIT_CONFIG_KEYS} = '.*';
+          '';
+        };
 
-      fcgiwrap = {
-        enable = true;
-        inherit user group;
+        fcgiwrap = {
+          enable = true;
+          inherit user group;
+        };
       };
-    };
   };
 }

Consider giving Nix/NixOS a try! <3