git.iko.soy/typeable/nixpkgs
on master help sign in
gitweb: use common options
commit2821d3fed74a209c8771402ce8058fd4188357ad authorgnidorah <gnidorah@users.noreply.github.com> dateThu 29 Mar 2018, 16:42 (9 years ago) parent69a0c97
4 files changed+57−60
nixos/modules/module-list.nix+1 nixos/modules/services/misc/gitweb.nix+50 nixos/modules/services/web-servers/lighttpd/gitweb.nix+3−30 nixos/modules/services/web-servers/nginx/gitweb.nix+3−30
nixos/modules/module-list.nix+1
@@ -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
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−30
@@ -3,13 +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− $highlight_bin = "${pkgs.highlight}/bin/highlight";
11− ${cfg.extraConfig}
12− '';
6+ cfg = config.services.gitweb;
137
148in
159{
@@ -24,30 +18,9 @@ in
2418 '';
2519 };
2620
27− projectroot = mkOption {
28− default = "/srv/git";
29− type = types.path;
30− description = ''
31− Path to git projects (bare repositories) that should be served by
32− gitweb. Must not end with a slash.
33− '';
34− };
35−
36− extraConfig = mkOption {
37− default = "";
38− type = types.lines;
39− description = ''
40− Verbatim configuration text appended to the generated gitweb.conf file.
41− '';
42− example = ''
43− $feature{'highlight'}{'default'} = [1];
44− $feature{'ctags'}{'default'} = [1];
45− '';
46− };
47−
4821 };
4922
50− config = mkIf cfg.enable {
23+ config = mkIf config.services.lighttpd.gitweb.enable {
5124
5225 # declare module dependencies
5326 services.lighttpd.enableModules = [ "mod_cgi" "mod_redirect" "mod_alias" "mod_setenv" ];
@@ -65,7 +38,7 @@ in
6538 "/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi"
6639 )
6740 setenv.add-environment = (
68− "GITWEB_CONFIG" => "${gitwebConfigFile}",
41+ "GITWEB_CONFIG" => "${cfg.gitwebConfigFile}",
6942 "HOME" => "${cfg.projectroot}"
7043 )
7144 }
nixos/modules/services/web-servers/nginx/gitweb.nix+3−30
@@ -3,13 +3,7 @@
33with lib;
44
55let
6− cfg = config.services.nginx.gitweb;
7− gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
8− # path to git projects (<project>.git)
9− $projectroot = "${cfg.projectroot}";
10− $highlight_bin = "${pkgs.highlight}/bin/highlight";
11− ${cfg.extraConfig}
12− '';
6+ cfg = config.services.gitweb;
137 gitwebPerlLibs = with pkgs.perlPackages; [ CGIFast FCGI FCGIProcManager HTMLTagCloud ];
148 git = pkgs.git.overrideAttrs (oldAttrs: rec {
159 postInstall = ''
@@ -34,30 +28,9 @@ in
3428 '';
3529 };
3630
37− projectroot = mkOption {
38− default = "/srv/git";
39− type = types.path;
40− description = ''
41− Path to git projects (bare repositories) that should be served by
42− gitweb. Must not end with a slash.
43− '';
44− };
45−
46− extraConfig = mkOption {
47− default = "";
48− type = types.lines;
49− description = ''
50− Verbatim configuration text appended to the generated gitweb.conf file.
51− '';
52− example = ''
53− $feature{'highlight'}{'default'} = [1];
54− $feature{'ctags'}{'default'} = [1];
55− '';
56− };
57−
5831 };
5932
60− config = mkIf cfg.enable {
33+ config = mkIf config.services.nginx.gitweb.enable {
6134
6235 systemd.sockets.gitweb = {
6336 description = "GitWeb Listen Socket";
@@ -87,7 +60,7 @@ in
8760 root = "${pkgs.git}/share/gitweb";
8861 extraConfig = ''
8962 include ${pkgs.nginx}/conf/fastcgi_params;
90− fastcgi_param GITWEB_CONFIG ${gitwebConfigFile};
63+ fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile};
9164 fastcgi_pass unix:/run/gitweb.sock;
9265 '';
9366 };