Merge pull request #37921 from gnidorah/gitweb

nixos/nginx: add gitweb sub-service
This commit is contained in:
Wout Mertens 2018-03-30 00:18:44 +02:00 committed by GitHub
commit b4e92e0b34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 132 additions and 26 deletions

View File

@ -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
@ -650,6 +651,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

View File

@ -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 (<project>.git)
$projectroot = "${cfg.projectroot}";
$highlight_bin = "${pkgs.highlight}/bin/highlight";
${cfg.extraConfig}
'';
type = types.path;
readOnly = true;
internal = true;
};
};
meta.maintainers = with maintainers; [ gnidorah ];
}

View File

@ -3,12 +3,7 @@
with lib;
let
cfg = config.services.lighttpd.gitweb;
gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
# path to git projects (<project>.git)
$projectroot = "${cfg.projectroot}";
${cfg.extraConfig}
'';
cfg = config.services.gitweb;
in
{
@ -23,26 +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.
'';
};
};
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" ];
@ -60,7 +38,7 @@ in
"/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi"
)
setenv.add-environment = (
"GITWEB_CONFIG" => "${gitwebConfigFile}",
"GITWEB_CONFIG" => "${cfg.gitwebConfigFile}",
"HOME" => "${cfg.projectroot}"
)
}

View File

@ -0,0 +1,64 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.gitweb;
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
'';
};
};
config = mkIf config.services.nginx.gitweb.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 ${cfg.gitwebConfigFile};
fastcgi_pass unix:/run/gitweb.sock;
'';
};
};
};
};
meta.maintainers = with maintainers; [ gnidorah ];
}

View File

@ -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

View File

@ -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 {