blob: b43faa44479c8cb1c942dea1100a08b8af6cb687 (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.eth.sites.cgit;
fcgi = config.services.fcgiwrap;
cgitConfig = pkgs.writeText "cgitrc" ''
cache-size=1000
virtual-root=/
about-filter=${cfg.aboutFilter}
source-filter=${cfg.sourceFilter}
remove-suffix=1
enable-git-config=1
#enable-gitweb-owner=1
project-list=${cfg.projectList}
scan-path=${cfg.scanPath}
enable-blame=1
enable-follow-links=1
enable-index-owner=0
enable-http-clone=1
snapshots=tar.gz zip
${cfg.extraConfig}
'';
in {
options.eth.sites.cgit = {
enable = mkEnableOption "Whether to enable cgit.";
https = mkOption {
type = types.bool;
default = true;
description = "Whether to enable HTTPS.";
};
virtualHost = mkOption {
type = types.str;
default = "_";
description = "Virtual Host to install the site under in Nginx.";
example = "git.eth.moe";
};
aboutFilter = mkOption {
type = types.path;
default = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
};
sourceFilter = mkOption {
type = types.path;
default = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
};
scanPath = mkOption {
type = types.path;
description = "Path to search for Git repositories under.";
example = "${config.services.gitolite.dataDir}/repositories/";
};
projectList = mkOption {
type = types.path;
description = "Path to a list of Git repositories to search for.";
example = "${config.services.gitolite.dataDir}/projects.list";
};
extraConfig = mkOption {
type = types.str;
default = "";
};
};
config = mkIf cfg.enable {
services.nginx.virtualHosts.${cfg.virtualHost} = {
forceSSL = cfg.https;
enableACME = cfg.https;
root = "${pkgs.cgit}/cgit/";
extraConfig = ''
try_files $uri @cgit;
location @cgit {
include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param CGIT_CONFIG ${cgitConfig};
fastcgi_param HTTP_HOST $server_name;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
fastcgi_pass unix:${fcgi.socketAddress};
}
'';
};
services.fcgiwrap = {
enable = true;
};
};
}
|