blob: 774e0521e4528a399606eb4d17cd07b4224dc57b (
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
{config, lib, pkgs, ...}: let
cfg = config.homelab.dev.git;
full-domain = lib.strings.concatStrings [cfg.subdomain "." cfg.domain];
in {
options.homelab.dev.git = {
enable = lib.mkEnableOption "git";
domain = lib.mkOption {
description = "The domain under which to serve the git server.";
type = lib.types.str;
default = config.networking.domain;
example = "example.com";
};
subdomain = lib.mkOption {
description = "The subdomain under which to serve the git server.";
type = lib.types.str;
default = "git";
example = "cgit";
};
};
config = lib.mkIf cfg.enable {
users.users."git" = {
isSystemUser = true;
description = lib.mkForce "git user";
home = lib.mkForce "/srv/git";
extraGroups = [ "git" ];
};
services.gitolite = {
enable = true;
user = "git";
group = "git";
adminPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMcc7hXixElOgv87LlY1LgCQ9oOT6Lj66wjCh1uRqpQt culsans@nzxt-desktop";
extraGitoliteRc = "$RC{GIT_CONFIG_KEYS} = '.*';";
dataDir = "/srv/git";
};
environment.etc."cgitrc".source = pkgs.writeText "cgitrc" (lib.generators.toKeyValue { } {
css = "/cgit.css";
# logo = "/cgit.png";
about-filter = "${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh";
# source-filter = "${pkgs.cgit-pink}/lib/cgit/filters/syntax-highlighting.py";
source-filter = lib.getExe pkgs.bat;
clone-url = (lib.concatStringsSep " " [
"https://$HTTP_HOST$SCRIPT_NAME/$CGIT_REPO_URL"
"ssh://git@${full-domain}:$CGIT_REPO_URL"
]);
enable-log-filecount = 1;
enable-log-linecount = 1;
enable-git-config = 1;
root-title = full-domain;
root-desc = "Culsans's Git Repositories";
scan-path = "/srv/git/repositories";
});
services.fcgiwrap.instances."cgit" = {
process = {
user = "git";
group = "git";
};
socket = {
mode = "0660";
group = "git";
user = "git";
};
};
# Configure caddy
services.caddy.virtualHosts.${full-domain}.extraConfig = ''
@assets path /cgit.css /cgit.js /cgit.png /favicon.ico /robots.txt
handle @assets {
root * /srv/www/${full-domain}
file_server
}
reverse_proxy unix//run/fcgiwrap-cgit.sock {
transport fastcgi {
env SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi
}
}
'';
users.users."caddy".extraGroups = [ "git" ];
};
}
|