diff options
| author | Kleidi Bujari <mail@4kb.net> | 2025-04-02 21:59:20 -0400 |
|---|---|---|
| committer | Kleidi Bujari <mail@4kb.net> | 2025-04-02 21:59:20 -0400 |
| commit | 09c2b6de63a6ff35348fcb2c2eb57b974f0a8a52 (patch) | |
| tree | bd8f1d3a51f12cd98764ae572b00f0b32de62644 /modules/xnet/gitserver | |
| parent | b1738c105de3bc0ba7cd27f68c9eb146439a0964 (diff) | |
| download | depot-09c2b6de63a6ff35348fcb2c2eb57b974f0a8a52.tar.gz depot-09c2b6de63a6ff35348fcb2c2eb57b974f0a8a52.tar.bz2 depot-09c2b6de63a6ff35348fcb2c2eb57b974f0a8a52.zip | |
automate project structure
Diffstat (limited to 'modules/xnet/gitserver')
| -rw-r--r-- | modules/xnet/gitserver/default.nix | 49 | ||||
| -rw-r--r-- | modules/xnet/gitserver/gitweb.nix | 70 |
2 files changed, 119 insertions, 0 deletions
diff --git a/modules/xnet/gitserver/default.nix b/modules/xnet/gitserver/default.nix new file mode 100644 index 0000000..2152ebd --- /dev/null +++ b/modules/xnet/gitserver/default.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.xnet.gitServer; + inherit (lib) mkOption mkIf types; +in +{ + imports = [ ./gitweb.nix ]; + + options.xnet.gitServer = { + enable = mkOption { + type = types.bool; + default = false; + description = "Serve git repos over SSH."; + }; + + path = mkOption { + type = types.path; + default = "/persist/repo/git"; + description = "Directory where repos will be stored."; + }; + }; + + config = mkIf cfg.enable { + users.users.git = { + group = "git"; + initialPassword = ""; + isSystemUser = true; + home = cfg.path; + homeMode = "755"; + createHome = true; + shell = "${pkgs.git}/bin/git-shell"; + openssh.authorizedKeys.keys = config.xnet.pubKeys; + }; + + users.groups.git = { }; + + programs.git = { + enable = true; + config = { + init = { + defaultBranch = "master"; + }; + safe = { + directory = "*"; + }; + }; + }; + }; +} diff --git a/modules/xnet/gitserver/gitweb.nix b/modules/xnet/gitserver/gitweb.nix new file mode 100644 index 0000000..da9a5ee --- /dev/null +++ b/modules/xnet/gitserver/gitweb.nix @@ -0,0 +1,70 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.xnet.gitServer.gitweb; + inherit (lib) mkOption mkIf types; +in +{ + options.xnet.gitServer.gitweb = { + enable = mkOption { + type = types.bool; + default = false; + description = "Enable web interface to git repos."; + }; + + hostName = mkOption { + type = types.str; + default = "src.web.4kb.net"; + description = "Hostname the webUI is served from."; + }; + }; + + config = mkIf cfg.enable { + xnet.nginx.enable = true; + + users.users.nginx.extraGroups = [ "git" ]; + services.cgit.main = { + enable = true; + scanPath = config.xnet.gitServer.path; + package = pkgs.cgit-pink; + nginx = { + virtualHost = cfg.hostName; + location = "/"; + }; + extraConfig = '' + mimetype.gif=image/gif + mimetype.html=text/html + mimetype.jpeg=image/jpeg + mimetype.jpg=image/jpeg + mimetype.pdf=application/pdf + mimetype.png=image/png + mimetype.svg=image/svg+xml + readme=:readme + readme=:readme.md + readme=:readme.txt + readme=:README + readme=:README.md + readme=:README.txt + ''; + settings = { + about-filter = "${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh"; + source-filter = "${pkgs.cgit-pink}/lib/cgit/filters/syntax-highlighting.py"; + clone-url = "https://${cfg.hostName}/$CGIT_REPO_URL git@${cfg.hostName}:$CGIT_REPO_URL"; + enable-commit-graph = true; + enable-http-clone = false; + enable-index-links = true; + enable-remote-branches = true; + remove-suffix = true; + robots = "noindex, nofollow"; + root-desc = "What I cannot create, I do not understand"; + root-title = cfg.hostName; + section-from-path = true; + snapshots = "tar.gz tar.bz2 zip"; + }; + }; + + # services.nginx.virtualHosts."${cfg.gitweb.hostName}" = { + # useACMEHost = "4kb.net"; + # addSSL = true; + # }; + }; +} |
