summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSilas Schöffel <sils@sils.li>2024-06-05 19:27:15 +0200
committerSilas Schöffel <sils@sils.li>2024-06-05 19:27:15 +0200
commit4215714cb11f2546b75a4316dc663ebe890a4fb6 (patch)
tree0132ea23449c073559c2a84d7bdb6b7172609ab9
parentfix(nix-sync): Don't try to exit in a subshell (diff)
downloadnixos-server-4215714cb11f2546b75a4316dc663ebe890a4fb6.tar.gz
nixos-server-4215714cb11f2546b75a4316dc663ebe890a4fb6.zip
feat(treewide): add git-server module
-rw-r--r--flake.nix1
-rw-r--r--hosts/server1/configuration.nix4
-rw-r--r--modules/nixos/default.nix5
-rw-r--r--modules/nixos/vhack/default.nix5
-rw-r--r--modules/nixos/vhack/git-server.nix35
5 files changed, 50 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
index 1d3e0fa..1706dec 100644
--- a/flake.nix
+++ b/flake.nix
@@ -98,6 +98,7 @@
           inherit pkgs-unstable;
         };
       modules = [
+        ./modules/nixos
         ./hosts/server1/configuration.nix
         simple-nixos-mailserver.nixosModule
         disko.nixosModules.default
diff --git a/hosts/server1/configuration.nix b/hosts/server1/configuration.nix
index 26de287..59dda92 100644
--- a/hosts/server1/configuration.nix
+++ b/hosts/server1/configuration.nix
@@ -6,6 +6,10 @@
     ../../system
   ];
 
+  vhack = {
+    git-server.enable = true;
+  };
+
   boot.tmp.cleanOnBoot = true;
   zramSwap.enable = true;
   networking.hostName = "server1";
diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix
new file mode 100644
index 0000000..fa21596
--- /dev/null
+++ b/modules/nixos/default.nix
@@ -0,0 +1,5 @@
+{...}: {
+  imports = [
+    ./vhack
+  ];
+}
diff --git a/modules/nixos/vhack/default.nix b/modules/nixos/vhack/default.nix
new file mode 100644
index 0000000..9f717c2
--- /dev/null
+++ b/modules/nixos/vhack/default.nix
@@ -0,0 +1,5 @@
+{...}: {
+  imports = [
+    ./git-server.nix
+  ];
+}
diff --git a/modules/nixos/vhack/git-server.nix b/modules/nixos/vhack/git-server.nix
new file mode 100644
index 0000000..162dcd0
--- /dev/null
+++ b/modules/nixos/vhack/git-server.nix
@@ -0,0 +1,35 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}: let
+  cfg = config.vhack.git-server;
+in {
+  options.vhack.git-server.enable = lib.mkEnableOption "a lightweight git-server,
+  realised with cgit and gitolite.";
+  config = lib.mkIf cfg.enable {
+    services = {
+      gitolite = {
+        enable = true;
+        adminPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAe4o1PM6VasT3KZNl5NYvgkkBrPOg36dqsywd10FztS openpgp:0x21D20D6A";
+        dataDir = "/srv/gitolite";
+        user = "gitolite";
+        group = "gitolite";
+        extraGitoliteRc = ''
+          $RC{UMASK} = 0027; # Enable group access, important for cgit.
+        '';
+      };
+      cgit."git.vhack.eu" = {
+        enable = true;
+        package = pkgs.cgit-pink;
+        scanPath = "${config.services.gitolite.dataDir}/repositories";
+        settings = {
+          section-from-path = true;
+          project-list = "${config.services.gitolite.dataDir}/projects.list";
+          source-filter = "${config.services.cgit."git.vhack.eu".package}/lib/cgit/filters/syntax-highlighting.py";
+        };
+      };
+    };
+  };
+}