blob: 07d40242030e2272b1e68812095e14e83b6ec716 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{pkgs, lib, config, ...}: let
inherit (lib) mkIf mkOption mkEnableOption types;
cfg = config.wilkuu.services.cgit;
cgit_dark = pkgs.fetchFromGitHub {
owner = "jb3";
repo = "cgit-dark";
rev = "f82cde4b29834d31465a5dafa00de527ef6853b0";
hash = "sha256-fSOelKDf1lHHRuyg/F81l8rAFrc6u7mAEFBX1Ua3V10=";
};
in {
options.wilkuu.services.cgit = {
enable = mkEnableOption "remote git and cgit";
domain = mkOption {
description = "Domain to run cgit on";
example = "git.wilkuu.xyz";
default = "git.${config.networking.hostName}.local";
type = types.str;
};
};
config = mkIf cfg.enable {
users.groups.git = {};
users.users.git = {
group = "git";
enable = true;
isSystemUser = true;
home = "/srv/git/";
createHome = true;
shell = "${pkgs.git}/bin/git-shell";
openssh.authorizedKeys.keyFiles = [
../secrets/${config.networking.hostName}/git_authorized_keys
];
};
services.openssh = {
enable = true;
extraConfig = ''
Match user git
AllowTcpForwarding no
AllowAgentForwarding no
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitTTY no
X11Forwarding no
'';
};
services.openssh.settings.AllowUsers = ["git"];
services.cgit."${cfg.domain}" = {
enable = true;
group = "git";
user = "git";
scanPath = "/srv/git";
settings = {
enable-follow-links = true;
source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
# css = "${cgit_dark}/cgit-themed.css";
# css = "https://raw.githubusercontent.com/jb3/cgit-dark/f82cde4b29834d31465a5dafa00de527ef6853b0/cgit-themed.css";
};
gitHttpBackend = {
enable = true;
checkExportOkFiles = false; # TODO: Reconsider later
};
};
services.nginx.virtualHosts.${cfg.domain} = {
forceSSL = true;
enableACME = true;
};
};
}
|