diff options
Diffstat (limited to 'nix/git.nix')
| -rw-r--r-- | nix/git.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/nix/git.nix b/nix/git.nix new file mode 100644 index 0000000..4b3b493 --- /dev/null +++ b/nix/git.nix @@ -0,0 +1,51 @@ +{config, pkgs, ...}: let + domain = "git.kassouni.net"; + repoRoot = "/srv/git"; +in { + users.users.git = { + isSystemUser = true; + group = "git"; + home = repoRoot; + createHome = true; + homeMode = "750"; + shell = "${pkgs.git}/bin/git-shell"; + openssh.authorizedKeys.keys = config.my.gitKeys; + }; + users.groups.git = { }; + + environment.systemPackages = [ pkgs.git ]; + + services.openssh.extraConfig = '' + Match user git + AllowTcpForwarding no + AllowAgentForwarding no + PermitTTY no + ''; + + services.cgit.${domain} = { + enable = true; + scanPath = repoRoot; + group = "git"; # so cgit can traverse a non-world-readable repoRoot + gitHttpBackend.checkExportOkFiles = true; + settings = { + strict-export = "git-daemon-export-ok"; + remove-suffix = true; + readme = [ ":README.md" ":README" ":readme.md" ]; + clone-url = "git@${domain}:$CGIT_REPO_URL https://${domain}/$CGIT_REPO_URL"; + source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py"; + about-filter = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh"; + }; + }; + + services.nginx.virtualHosts.${domain} = { + forceSSL = true; + enableACME = true; + }; + + security.acme = { + acceptTerms = true; + defaults.email = "alex@kassouni.net"; + }; + + networking.firewall.allowedTCPPorts = [ 80 443 ]; +} |