nixos/gitweb: add gitwebTheme option

This commit is contained in:
gnidorah 2018-04-17 20:06:44 +03:00
parent a415a95e7c
commit 9029ed933c
7 changed files with 65 additions and 19 deletions

View File

@ -32,6 +32,14 @@ in
''; '';
}; };
gitwebTheme = mkOption {
default = false;
type = types.bool;
description = ''
Use an alternative theme for gitweb, strongly inspired by GitHub.
'';
};
gitwebConfigFile = mkOption { gitwebConfigFile = mkOption {
default = pkgs.writeText "gitweb.conf" '' default = pkgs.writeText "gitweb.conf" ''
# path to git projects (<project>.git) # path to git projects (<project>.git)

View File

@ -4,6 +4,9 @@ with lib;
let let
cfg = config.services.gitweb; cfg = config.services.gitweb;
package = pkgs.gitweb.override (optionalAttrs cfg.gitwebTheme {
gitwebTheme = true;
});
in in
{ {
@ -34,8 +37,8 @@ in
"^/gitweb$" => "/gitweb/" "^/gitweb$" => "/gitweb/"
) )
alias.url = ( alias.url = (
"/gitweb/static/" => "${pkgs.git}/share/gitweb/static/", "/gitweb/static/" => "${package}/static/",
"/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi" "/gitweb/" => "${package}/gitweb.cgi"
) )
setenv.add-environment = ( setenv.add-environment = (
"GITWEB_CONFIG" => "${cfg.gitwebConfigFile}", "GITWEB_CONFIG" => "${cfg.gitwebConfigFile}",

View File

@ -4,6 +4,9 @@ with lib;
let let
cfg = config.services.gitweb; cfg = config.services.gitweb;
package = pkgs.gitweb.override (optionalAttrs cfg.gitwebTheme {
gitwebTheme = true;
});
in in
{ {
@ -24,7 +27,7 @@ in
systemd.services.gitweb = { systemd.services.gitweb = {
description = "GitWeb service"; description = "GitWeb service";
script = "${pkgs.git}/share/gitweb/gitweb.cgi --fastcgi --nproc=1"; script = "${package}/gitweb.cgi --fastcgi --nproc=1";
environment = { environment = {
FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock"; FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock";
}; };
@ -38,11 +41,10 @@ in
services.nginx = { services.nginx = {
virtualHosts.default = { virtualHosts.default = {
locations."/gitweb/" = { locations."/gitweb/static/" = {
root = "${pkgs.git}/share"; alias = "${package}/static/";
tryFiles = "$uri @gitweb";
}; };
locations."@gitweb" = { locations."/gitweb/" = {
extraConfig = '' extraConfig = ''
include ${pkgs.nginx}/conf/fastcgi_params; include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile}; fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile};

View File

@ -15,7 +15,6 @@ let
perlPackages.MIMEBase64 perlPackages.AuthenSASL perlPackages.MIMEBase64 perlPackages.AuthenSASL
perlPackages.DigestHMAC perlPackages.DigestHMAC
]; ];
gitwebPerlLibs = with perlPackages; [ CGI HTMLParser CGIFast FCGI FCGIProcManager HTMLTagCloud ];
}; };
in in

View File

@ -1,9 +1,9 @@
{ fetchurl, stdenv, curl, openssl, zlib, expat, perl, python, gettext, cpio { fetchurl, stdenv, curl, openssl, zlib, expat, perl, python, gettext, cpio
, gnugrep, gnused, gawk, coreutils # needed at runtime by git-filter-branch etc , gnugrep, gnused, gawk, coreutils # needed at runtime by git-filter-branch etc
, gzip, openssh, pcre2 , openssh, pcre2
, asciidoc, texinfo, xmlto, docbook2x, docbook_xsl, docbook_xml_dtd_45 , asciidoc, texinfo, xmlto, docbook2x, docbook_xsl, docbook_xml_dtd_45
, libxslt, tcl, tk, makeWrapper, libiconv , libxslt, tcl, tk, makeWrapper, libiconv
, svnSupport, subversionClient, perlLibs, smtpPerlLibs, gitwebPerlLibs , svnSupport, subversionClient, perlLibs, smtpPerlLibs
, guiSupport , guiSupport
, withManual ? true , withManual ? true
, pythonSupport ? true , pythonSupport ? true
@ -25,6 +25,8 @@ stdenv.mkDerivation {
sha256 = "0j1dwvg5llnj3g0fp8hdgpms4hp90qw9f6509vqw30dhwplrjpfn"; sha256 = "0j1dwvg5llnj3g0fp8hdgpms4hp90qw9f6509vqw30dhwplrjpfn";
}; };
outputs = [ "out" "gitweb" ];
hardeningDisable = [ "format" ]; hardeningDisable = [ "format" ];
patches = [ patches = [
@ -131,15 +133,8 @@ stdenv.mkDerivation {
substituteInPlace $out/libexec/git-core/git-sh-i18n \ substituteInPlace $out/libexec/git-core/git-sh-i18n \
--subst-var-by gettext ${gettext} --subst-var-by gettext ${gettext}
# gzip (and optionally bzip2, xz, zip) are runtime dependencies for # put in separate package for simpler maintenance
# gitweb.cgi, need to patch so that it's found mv $out/share/gitweb $gitweb/
sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${gzip}/bin/gzip'|" \
$out/share/gitweb/gitweb.cgi
# Give access to CGI.pm and friends (was removed from perl core in 5.22)
for p in ${stdenv.lib.concatStringsSep " " gitwebPerlLibs}; do
sed -i -e "/use CGI /i use lib \"$p/lib/perl5/site_perl\";" \
"$out/share/gitweb/gitweb.cgi"
done
# Also put git-http-backend into $PATH, so that we can use smart # Also put git-http-backend into $PATH, so that we can use smart
# HTTP(s) transports for pushing # HTTP(s) transports for pushing

View File

@ -0,0 +1,37 @@
{ stdenv, git, gzip, perlPackages, fetchFromGitHub
, gitwebTheme ? false }:
let
gitwebPerlLibs = with perlPackages; [ CGI HTMLParser CGIFast FCGI FCGIProcManager HTMLTagCloud ];
gitwebThemeSrc = fetchFromGitHub {
owner = "kogakure";
repo = "gitweb-theme";
rev = "049b88e664a359f8ec25dc6f531b7e2aa60dd1a2";
sha256 = "0wksqma41z36dbv6w6iplkjfdm0ha3njp222fakyh4lismajr71p";
};
in stdenv.mkDerivation {
name = "gitweb";
src = git.gitweb;
installPhase = ''
mkdir $out
mv * $out
# gzip (and optionally bzip2, xz, zip) are runtime dependencies for
# gitweb.cgi, need to patch so that it's found
sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${gzip}/bin/gzip'|" \
$out/gitweb.cgi
# Give access to CGI.pm and friends (was removed from perl core in 5.22)
for p in ${stdenv.lib.concatStringsSep " " gitwebPerlLibs}; do
sed -i -e "/use CGI /i use lib \"$p/lib/perl5/site_perl\";" \
"$out/gitweb.cgi"
done
${stdenv.lib.optionalString gitwebTheme "cp ${gitwebThemeSrc}/* $out/static"}
'';
meta = git.meta // {
maintainers = with stdenv.lib.maintainers; [ gnidorah ];
};
}

View File

@ -15613,6 +15613,8 @@ with pkgs;
ghostwriter = libsForQt5.callPackage ../applications/editors/ghostwriter { }; ghostwriter = libsForQt5.callPackage ../applications/editors/ghostwriter { };
gitweb = callPackage ../applications/version-management/git-and-tools/gitweb/default.nix { };
gksu = callPackage ../applications/misc/gksu { }; gksu = callPackage ../applications/misc/gksu { };
gnss-sdr = callPackage ../applications/misc/gnss-sdr { }; gnss-sdr = callPackage ../applications/misc/gnss-sdr { };