git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #37921 from gnidorah/gitweb

nixos/nginx: add gitweb sub-service

commitb4e92e0b34e72ed467fe4ed4fa1c5a1dfa3c89b7 authorWout Mertens <Wout.Mertens@gmail.com> dateFri 30 Mar 2018, 00:18 (9 years ago) parent299eb8705b535c
6 files changed+132−26
nixos/modules/module-list.nix+2 nixos/modules/services/misc/gitweb.nix+50 nixos/modules/services/web-servers/lighttpd/gitweb.nix+3−25 nixos/modules/services/web-servers/nginx/gitweb.nix+64 pkgs/applications/version-management/git-and-tools/default.nix+1−1 pkgs/top-level/perl-packages.nix+12
nixos/modules/module-list.nix+2
@@ -325,6 +325,7 @@
325325 #./services/misc/gitit.nix
326326 #./services/misc/gitlab.nix
327327 ./services/misc/gitolite.nix
328+ ./services/misc/gitweb.nix
328329 ./services/misc/gogs.nix
329330 ./services/misc/gollum.nix
330331 ./services/misc/gpsd.nix
@@ -650,6 +651,7 @@
650651 ./services/web-servers/mighttpd2.nix
651652 ./services/web-servers/minio.nix
652653 ./services/web-servers/nginx/default.nix
654+ ./services/web-servers/nginx/gitweb.nix
653655 ./services/web-servers/phpfpm/default.nix
654656 ./services/web-servers/shellinabox.nix
655657 ./services/web-servers/tomcat.nix
nixos/modules/services/misc/gitweb.nixnew file+50
@@ -0,0 +1,50 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.gitweb;
7+
8+in
9+{
10+
11+ options.services.gitweb = {
12+
13+ projectroot = mkOption {
14+ default = "/srv/git";
15+ type = types.path;
16+ description = ''
17+ Path to git projects (bare repositories) that should be served by
18+ gitweb. Must not end with a slash.
19+ '';
20+ };
21+
22+ extraConfig = mkOption {
23+ default = "";
24+ type = types.lines;
25+ description = ''
26+ Verbatim configuration text appended to the generated gitweb.conf file.
27+ '';
28+ example = ''
29+ $feature{'highlight'}{'default'} = [1];
30+ $feature{'ctags'}{'default'} = [1];
31+ '';
32+ };
33+
34+ gitwebConfigFile = mkOption {
35+ default = pkgs.writeText "gitweb.conf" ''
36+ # path to git projects (<project>.git)
37+ $projectroot = "${cfg.projectroot}";
38+ $highlight_bin = "${pkgs.highlight}/bin/highlight";
39+ ${cfg.extraConfig}
40+ '';
41+ type = types.path;
42+ readOnly = true;
43+ internal = true;
44+ };
45+
46+ };
47+
48+ meta.maintainers = with maintainers; [ gnidorah ];
49+
50+}
nixos/modules/services/web-servers/lighttpd/gitweb.nix+3−25
@@ -3,12 +3,7 @@
33with lib;
44
55let
6− cfg = config.services.lighttpd.gitweb;
7− gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
8− # path to git projects (<project>.git)
9− $projectroot = "${cfg.projectroot}";
10− ${cfg.extraConfig}
11− '';
6+ cfg = config.services.gitweb;
127
138in
149{
@@ -23,26 +18,9 @@ in
2318 '';
2419 };
2520
26− projectroot = mkOption {
27− default = "/srv/git";
28− type = types.path;
29− description = ''
30− Path to git projects (bare repositories) that should be served by
31− gitweb. Must not end with a slash.
32− '';
33− };
34−
35− extraConfig = mkOption {
36− default = "";
37− type = types.lines;
38− description = ''
39− Verbatim configuration text appended to the generated gitweb.conf file.
40− '';
41− };
42−
4321 };
4422
45− config = mkIf cfg.enable {
23+ config = mkIf config.services.lighttpd.gitweb.enable {
4624
4725 # declare module dependencies
4826 services.lighttpd.enableModules = [ "mod_cgi" "mod_redirect" "mod_alias" "mod_setenv" ];
@@ -60,7 +38,7 @@ in
6038 "/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi"
6139 )
6240 setenv.add-environment = (
63− "GITWEB_CONFIG" => "${gitwebConfigFile}",
41+ "GITWEB_CONFIG" => "${cfg.gitwebConfigFile}",
6442 "HOME" => "${cfg.projectroot}"
6543 )
6644 }
nixos/modules/services/web-servers/nginx/gitweb.nixnew file+64
@@ -0,0 +1,64 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.gitweb;
7+
8+in
9+{
10+
11+ options.services.nginx.gitweb = {
12+
13+ enable = mkOption {
14+ default = false;
15+ type = types.bool;
16+ description = ''
17+ If true, enable gitweb in nginx. Access it at http://yourserver/gitweb
18+ '';
19+ };
20+
21+ };
22+
23+ config = mkIf config.services.nginx.gitweb.enable {
24+
25+ systemd.sockets.gitweb = {
26+ description = "GitWeb Listen Socket";
27+ listenStreams = [ "/run/gitweb.sock" ];
28+ socketConfig = {
29+ Accept = "false";
30+ SocketUser = "nginx";
31+ SocketGroup = "nginx";
32+ SocketMode = "0600";
33+ };
34+ wantedBy = [ "sockets.target" ];
35+ };
36+ systemd.services.gitweb = {
37+ description = "GitWeb service";
38+ script = "${git}/share/gitweb/gitweb.cgi --fcgi";
39+ serviceConfig = {
40+ Type = "simple";
41+ StandardInput = "socket";
42+ User = "nginx";
43+ Group = "nginx";
44+ };
45+ };
46+
47+ services.nginx = {
48+ virtualHosts.default = {
49+ locations."/gitweb" = {
50+ root = "${pkgs.git}/share/gitweb";
51+ extraConfig = ''
52+ include ${pkgs.nginx}/conf/fastcgi_params;
53+ fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile};
54+ fastcgi_pass unix:/run/gitweb.sock;
55+ '';
56+ };
57+ };
58+ };
59+
60+ };
61+
62+ meta.maintainers = with maintainers; [ gnidorah ];
63+
64+}
pkgs/applications/version-management/git-and-tools/default.nix+1−1
@@ -15,7 +15,7 @@ let
1515 perlPackages.MIMEBase64 perlPackages.AuthenSASL
1616 perlPackages.DigestHMAC
1717 ];
18− gitwebPerlLibs = with perlPackages; [ CGI HTMLParser ];
18+ gitwebPerlLibs = with perlPackages; [ CGI HTMLParser CGIFast FCGI FCGIProcManager HTMLTagCloud ];
1919 };
2020
2121in
pkgs/top-level/perl-packages.nix+12
@@ -6743,6 +6743,18 @@ let self = _self // overrides; _self = with self; {
67436743 };
67446744 };
67456745
6746+ HTMLTagCloud = buildPerlPackage rec {
6747+ name = "HTML-TagCloud-0.38";
6748+ src = fetchurl {
6749+ url = "mirror://cpan/authors/id/R/RO/ROBERTSD/${name}.tar.gz";
6750+ sha256 = "05bhnrwwlwd6cj3cn91zw5r99xddvy142bznid26p1pg5m3rk029";
6751+ };
6752+ meta = {
6753+ description = "Generate An HTML Tag Cloud";
6754+ license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ];
6755+ };
6756+ };
6757+
67466758 HTMLQuoted = buildPerlPackage {
67476759 name = "HTML-Quoted-0.04";
67486760 src = fetchurl {