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
|
{
pkgs,
jolheiser,
config,
lib,
...
}:
let
enable = true;
port = 9454;
in
lib.mkIf enable {
services = {
gollum = {
enable = true;
stateDir = "/var/lib/ugit/repos/wiki.git";
emoji = true;
h1-title = true;
inherit port;
branch = "main";
user = "ugit";
group = "ugit";
};
caddy.virtualHosts."wiki.${jolheiser.domain}".extraConfig = ''
handle /oauth2/* {
reverse_proxy localhost:6227 {
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Uri {uri}
}
}
handle {
forward_auth localhost:6227 {
uri /oauth2/auth
header_up X-Real-IP {remote_host}
@error status 401
handle_response @error {
redir * /oauth2/sign_in?rd={scheme}://{host}{uri}
}
}
reverse_proxy localhost:${builtins.toString port}
}
'';
};
# Hack to work with bare repos
systemd.services.gollum =
let
cfg = config.services.gollum;
in
{
preStart = pkgs.lib.mkForce ''
git init --bare ${cfg.stateDir}
'';
serviceConfig.ExecStart = pkgs.lib.mkForce ''
${cfg.package}/bin/gollum \
--port ${toString cfg.port} \
--host ${cfg.address} \
--config ${pkgs.writeText "gollum-config.rb" cfg.extraConfig} \
--ref ${cfg.branch} \
${pkgs.lib.optionalString cfg.math "--math"} \
${pkgs.lib.optionalString cfg.emoji "--emoji"} \
${pkgs.lib.optionalString cfg.h1-title "--h1-title"} \
${pkgs.lib.optionalString cfg.no-edit "--no-edit"} \
${pkgs.lib.optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
${pkgs.lib.optionalString (cfg.user-icons != null) "--user-icons ${cfg.user-icons}"} \
--bare \
--css \
--js \
${cfg.stateDir}
'';
};
}
|