From 9e6752075a9b456f37e637bdcaffa123038fbf0a Mon Sep 17 00:00:00 2001 From: gnidorah Date: Wed, 28 Mar 2018 12:02:57 +0300 Subject: [PATCH 1/4] perlPackages.HTMLTagCloud: init at 0.38 --- pkgs/top-level/perl-packages.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix index 13554ff6ee68..18800e553bb1 100644 --- a/pkgs/top-level/perl-packages.nix +++ b/pkgs/top-level/perl-packages.nix @@ -6743,6 +6743,18 @@ let self = _self // overrides; _self = with self; { }; }; + HTMLTagCloud = buildPerlPackage rec { + name = "HTML-TagCloud-0.38"; + src = fetchurl { + url = "mirror://cpan/authors/id/R/RO/ROBERTSD/${name}.tar.gz"; + sha256 = "05bhnrwwlwd6cj3cn91zw5r99xddvy142bznid26p1pg5m3rk029"; + }; + meta = { + description = "Generate An HTML Tag Cloud"; + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + HTMLQuoted = buildPerlPackage { name = "HTML-Quoted-0.04"; src = fetchurl { From 69a0c9721e4cd66739971d499a67988f8412e5d7 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Tue, 27 Mar 2018 19:42:13 +0300 Subject: [PATCH 2/4] nixos/nginx: add gitweb sub-service --- nixos/modules/module-list.nix | 1 + .../services/web-servers/lighttpd/gitweb.nix | 5 + .../services/web-servers/nginx/gitweb.nix | 101 ++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 nixos/modules/services/web-servers/nginx/gitweb.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 9e232ce1f4e6..b5bc8b6b9de4 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -650,6 +650,7 @@ ./services/web-servers/mighttpd2.nix ./services/web-servers/minio.nix ./services/web-servers/nginx/default.nix + ./services/web-servers/nginx/gitweb.nix ./services/web-servers/phpfpm/default.nix ./services/web-servers/shellinabox.nix ./services/web-servers/tomcat.nix diff --git a/nixos/modules/services/web-servers/lighttpd/gitweb.nix b/nixos/modules/services/web-servers/lighttpd/gitweb.nix index c8d9836b0b68..2f220c9ec53d 100644 --- a/nixos/modules/services/web-servers/lighttpd/gitweb.nix +++ b/nixos/modules/services/web-servers/lighttpd/gitweb.nix @@ -7,6 +7,7 @@ let gitwebConfigFile = pkgs.writeText "gitweb.conf" '' # path to git projects (.git) $projectroot = "${cfg.projectroot}"; + $highlight_bin = "${pkgs.highlight}/bin/highlight"; ${cfg.extraConfig} ''; @@ -38,6 +39,10 @@ in description = '' Verbatim configuration text appended to the generated gitweb.conf file. ''; + example = '' + $feature{'highlight'}{'default'} = [1]; + $feature{'ctags'}{'default'} = [1]; + ''; }; }; diff --git a/nixos/modules/services/web-servers/nginx/gitweb.nix b/nixos/modules/services/web-servers/nginx/gitweb.nix new file mode 100644 index 000000000000..315da66fab63 --- /dev/null +++ b/nixos/modules/services/web-servers/nginx/gitweb.nix @@ -0,0 +1,101 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.nginx.gitweb; + gitwebConfigFile = pkgs.writeText "gitweb.conf" '' + # path to git projects (.git) + $projectroot = "${cfg.projectroot}"; + $highlight_bin = "${pkgs.highlight}/bin/highlight"; + ${cfg.extraConfig} + ''; + gitwebPerlLibs = with pkgs.perlPackages; [ CGIFast FCGI FCGIProcManager HTMLTagCloud ]; + git = pkgs.git.overrideAttrs (oldAttrs: rec { + postInstall = '' + ${oldAttrs.postInstall} + for p in ${lib.concatStringsSep " " gitwebPerlLibs}; do + sed -i -e "/use CGI /i use lib \"$p/lib/perl5/site_perl\";" \ + "$out/share/gitweb/gitweb.cgi" + done + ''; + }); + +in +{ + + options.services.nginx.gitweb = { + + enable = mkOption { + default = false; + type = types.bool; + description = '' + If true, enable gitweb in nginx. Access it at http://yourserver/gitweb + ''; + }; + + projectroot = mkOption { + default = "/srv/git"; + type = types.path; + description = '' + Path to git projects (bare repositories) that should be served by + gitweb. Must not end with a slash. + ''; + }; + + extraConfig = mkOption { + default = ""; + type = types.lines; + description = '' + Verbatim configuration text appended to the generated gitweb.conf file. + ''; + example = '' + $feature{'highlight'}{'default'} = [1]; + $feature{'ctags'}{'default'} = [1]; + ''; + }; + + }; + + config = mkIf cfg.enable { + + systemd.sockets.gitweb = { + description = "GitWeb Listen Socket"; + listenStreams = [ "/run/gitweb.sock" ]; + socketConfig = { + Accept = "false"; + SocketUser = "nginx"; + SocketGroup = "nginx"; + SocketMode = "0600"; + }; + wantedBy = [ "sockets.target" ]; + }; + systemd.services.gitweb = { + description = "GitWeb service"; + script = "${git}/share/gitweb/gitweb.cgi --fcgi"; + serviceConfig = { + Type = "simple"; + StandardInput = "socket"; + User = "nginx"; + Group = "nginx"; + }; + }; + + services.nginx = { + virtualHosts.default = { + locations."/gitweb" = { + root = "${pkgs.git}/share/gitweb"; + extraConfig = '' + include ${pkgs.nginx}/conf/fastcgi_params; + fastcgi_param GITWEB_CONFIG ${gitwebConfigFile}; + fastcgi_pass unix:/run/gitweb.sock; + ''; + }; + }; + }; + + }; + + meta.maintainers = with maintainers; [ gnidorah ]; + +} From 2821d3fed74a209c8771402ce8058fd4188357ad Mon Sep 17 00:00:00 2001 From: gnidorah Date: Thu, 29 Mar 2018 16:42:49 +0300 Subject: [PATCH 3/4] gitweb: use common options --- nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/gitweb.nix | 50 +++++++++++++++++++ .../services/web-servers/lighttpd/gitweb.nix | 33 ++---------- .../services/web-servers/nginx/gitweb.nix | 33 ++---------- 4 files changed, 57 insertions(+), 60 deletions(-) create mode 100644 nixos/modules/services/misc/gitweb.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index b5bc8b6b9de4..1a73cef984eb 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -325,6 +325,7 @@ #./services/misc/gitit.nix ./services/misc/gitlab.nix ./services/misc/gitolite.nix + ./services/misc/gitweb.nix ./services/misc/gogs.nix ./services/misc/gollum.nix ./services/misc/gpsd.nix diff --git a/nixos/modules/services/misc/gitweb.nix b/nixos/modules/services/misc/gitweb.nix new file mode 100644 index 000000000000..8e4d85a1e15f --- /dev/null +++ b/nixos/modules/services/misc/gitweb.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.gitweb; + +in +{ + + options.services.gitweb = { + + projectroot = mkOption { + default = "/srv/git"; + type = types.path; + description = '' + Path to git projects (bare repositories) that should be served by + gitweb. Must not end with a slash. + ''; + }; + + extraConfig = mkOption { + default = ""; + type = types.lines; + description = '' + Verbatim configuration text appended to the generated gitweb.conf file. + ''; + example = '' + $feature{'highlight'}{'default'} = [1]; + $feature{'ctags'}{'default'} = [1]; + ''; + }; + + gitwebConfigFile = mkOption { + default = pkgs.writeText "gitweb.conf" '' + # path to git projects (.git) + $projectroot = "${cfg.projectroot}"; + $highlight_bin = "${pkgs.highlight}/bin/highlight"; + ${cfg.extraConfig} + ''; + type = types.path; + readOnly = true; + internal = true; + }; + + }; + + meta.maintainers = with maintainers; [ gnidorah ]; + +} diff --git a/nixos/modules/services/web-servers/lighttpd/gitweb.nix b/nixos/modules/services/web-servers/lighttpd/gitweb.nix index 2f220c9ec53d..37128d90401d 100644 --- a/nixos/modules/services/web-servers/lighttpd/gitweb.nix +++ b/nixos/modules/services/web-servers/lighttpd/gitweb.nix @@ -3,13 +3,7 @@ with lib; let - cfg = config.services.lighttpd.gitweb; - gitwebConfigFile = pkgs.writeText "gitweb.conf" '' - # path to git projects (.git) - $projectroot = "${cfg.projectroot}"; - $highlight_bin = "${pkgs.highlight}/bin/highlight"; - ${cfg.extraConfig} - ''; + cfg = config.services.gitweb; in { @@ -24,30 +18,9 @@ in ''; }; - projectroot = mkOption { - default = "/srv/git"; - type = types.path; - description = '' - Path to git projects (bare repositories) that should be served by - gitweb. Must not end with a slash. - ''; - }; - - extraConfig = mkOption { - default = ""; - type = types.lines; - description = '' - Verbatim configuration text appended to the generated gitweb.conf file. - ''; - example = '' - $feature{'highlight'}{'default'} = [1]; - $feature{'ctags'}{'default'} = [1]; - ''; - }; - }; - config = mkIf cfg.enable { + config = mkIf config.services.lighttpd.gitweb.enable { # declare module dependencies services.lighttpd.enableModules = [ "mod_cgi" "mod_redirect" "mod_alias" "mod_setenv" ]; @@ -65,7 +38,7 @@ in "/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi" ) setenv.add-environment = ( - "GITWEB_CONFIG" => "${gitwebConfigFile}", + "GITWEB_CONFIG" => "${cfg.gitwebConfigFile}", "HOME" => "${cfg.projectroot}" ) } diff --git a/nixos/modules/services/web-servers/nginx/gitweb.nix b/nixos/modules/services/web-servers/nginx/gitweb.nix index 315da66fab63..068bf5593e9f 100644 --- a/nixos/modules/services/web-servers/nginx/gitweb.nix +++ b/nixos/modules/services/web-servers/nginx/gitweb.nix @@ -3,13 +3,7 @@ with lib; let - cfg = config.services.nginx.gitweb; - gitwebConfigFile = pkgs.writeText "gitweb.conf" '' - # path to git projects (.git) - $projectroot = "${cfg.projectroot}"; - $highlight_bin = "${pkgs.highlight}/bin/highlight"; - ${cfg.extraConfig} - ''; + cfg = config.services.gitweb; gitwebPerlLibs = with pkgs.perlPackages; [ CGIFast FCGI FCGIProcManager HTMLTagCloud ]; git = pkgs.git.overrideAttrs (oldAttrs: rec { postInstall = '' @@ -34,30 +28,9 @@ in ''; }; - projectroot = mkOption { - default = "/srv/git"; - type = types.path; - description = '' - Path to git projects (bare repositories) that should be served by - gitweb. Must not end with a slash. - ''; - }; - - extraConfig = mkOption { - default = ""; - type = types.lines; - description = '' - Verbatim configuration text appended to the generated gitweb.conf file. - ''; - example = '' - $feature{'highlight'}{'default'} = [1]; - $feature{'ctags'}{'default'} = [1]; - ''; - }; - }; - config = mkIf cfg.enable { + config = mkIf config.services.nginx.gitweb.enable { systemd.sockets.gitweb = { description = "GitWeb Listen Socket"; @@ -87,7 +60,7 @@ in root = "${pkgs.git}/share/gitweb"; extraConfig = '' include ${pkgs.nginx}/conf/fastcgi_params; - fastcgi_param GITWEB_CONFIG ${gitwebConfigFile}; + fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile}; fastcgi_pass unix:/run/gitweb.sock; ''; }; From 05b535c850d1361e18ecd58ba81a8537bf31041b Mon Sep 17 00:00:00 2001 From: gnidorah Date: Wed, 28 Mar 2018 12:27:19 +0300 Subject: [PATCH 4/4] git: add more deps to gitweb --- nixos/modules/services/web-servers/nginx/gitweb.nix | 10 ---------- .../version-management/git-and-tools/default.nix | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/nixos/modules/services/web-servers/nginx/gitweb.nix b/nixos/modules/services/web-servers/nginx/gitweb.nix index 068bf5593e9f..344c1f7b8aa4 100644 --- a/nixos/modules/services/web-servers/nginx/gitweb.nix +++ b/nixos/modules/services/web-servers/nginx/gitweb.nix @@ -4,16 +4,6 @@ with lib; let cfg = config.services.gitweb; - gitwebPerlLibs = with pkgs.perlPackages; [ CGIFast FCGI FCGIProcManager HTMLTagCloud ]; - git = pkgs.git.overrideAttrs (oldAttrs: rec { - postInstall = '' - ${oldAttrs.postInstall} - for p in ${lib.concatStringsSep " " gitwebPerlLibs}; do - sed -i -e "/use CGI /i use lib \"$p/lib/perl5/site_perl\";" \ - "$out/share/gitweb/gitweb.cgi" - done - ''; - }); in { diff --git a/pkgs/applications/version-management/git-and-tools/default.nix b/pkgs/applications/version-management/git-and-tools/default.nix index e5e36e998ace..e2c525963d28 100644 --- a/pkgs/applications/version-management/git-and-tools/default.nix +++ b/pkgs/applications/version-management/git-and-tools/default.nix @@ -15,7 +15,7 @@ let perlPackages.MIMEBase64 perlPackages.AuthenSASL perlPackages.DigestHMAC ]; - gitwebPerlLibs = with perlPackages; [ CGI HTMLParser ]; + gitwebPerlLibs = with perlPackages; [ CGI HTMLParser CGIFast FCGI FCGIProcManager HTMLTagCloud ]; }; in