about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-09-22 13:27:34 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-09-22 20:36:55 +0200
commit3c3c8b339c5c8a694a9fcff7118c34896ae358e7 (patch)
treee1534b43a1f56afac5a475216c5e009583396ce4 /modules
parentHome: Git: Add send-email 'account' (diff)
downloadnixos-config-3c3c8b339c5c8a694a9fcff7118c34896ae358e7.tar.gz
nixos-config-3c3c8b339c5c8a694a9fcff7118c34896ae358e7.tar.bz2
nixos-config-3c3c8b339c5c8a694a9fcff7118c34896ae358e7.zip
Modules: Add git-server module
This adds a git server (gitolite) with a web frontend cgit
Diffstat (limited to 'modules')
-rw-r--r--modules/git-server/default.nix86
1 files changed, 86 insertions, 0 deletions
diff --git a/modules/git-server/default.nix b/modules/git-server/default.nix
new file mode 100644
index 0000000..24b9a61
--- /dev/null
+++ b/modules/git-server/default.nix
@@ -0,0 +1,86 @@
+{ pkgs, config, ... }:
+let
+  dataDir = "/home/git"; #needs to be created and owned by ${user}
+  cgitPackage = pkgs.cgit;
+  user = "git";
+  group = "git";
+  adminPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID99gQ/AgXhgwAjs+opsRXMbWpXFRT2aqAOUbN3DsrhQ";
+in
+{
+  environment.systemPackages = [
+    cgitPackage
+  ];
+
+  services = {
+    nginx = {
+      enable = true;
+      virtualHosts."_" = {
+        listen = [{ addr = "0.0.0.0"; port = 80; }];
+        locations = {
+          "/".extraConfig =
+            let
+              cgitrc = pkgs.writeText "cgitrc" ''
+                root-title=Baitinq's git
+                root-desc=Hi!
+
+                about-filter=${cgitPackage}/lib/cgit/filters/about-formatting.sh
+                source-filter=${cgitPackage}/lib/cgit/filters/syntax-highlighting.py
+                commit-filter=${cgitPackage}/lib/cgit/filters/commit-links.sh
+
+
+                enable-blame=1
+                enable-commit-graph=1
+                enable-follow-links=1
+                enable-git-config=1
+                enable-html-serving=1
+                enable-index-links=1
+                enable-index-owner=0
+                enable-log-filecount=1
+                enable-log-linecount=1
+                enable-remote-branches=1
+                enable-subject-links=1
+                enable-tree-linenumbers=1
+
+                remove-suffix=1
+
+                snapshots=tar.gz tar.bz2 zip
+
+                readme=:README
+                readme=:README.md
+                readme=:README.org
+                readme=:README.txt
+                readme=:readme
+                readme=:readme.md
+                readme=:readme.org
+                readme=:readme.txt
+
+                project-list=${config.services.gitolite.dataDir}/projects.list
+                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 ${cgitPackage}/cgit/cgit.cgi;
+                fastcgi_param CGIT_CONFIG ${cgitrc};
+                fastcgi_param PATH_INFO $uri;
+                fastcgi_param QUERY_STRING $args;
+                fastcgi_param HTTP_HOST $server_name; '';
+          "~* ^/(.+.(ico|css|png))$".extraConfig = ''
+            alias ${cgitPackage}/cgit/$1;
+          '';
+        };
+      };
+    };
+
+    gitolite = {
+      enable = true;
+      inherit user group adminPubkey dataDir;
+    };
+
+    fcgiwrap = {
+      enable = true;
+      inherit user group;
+    };
+  };
+}