From 813c6d46641976befcfdfdb1bdaaf7a84bb34d03 Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Sun, 6 Jan 2019 14:41:22 +0300 Subject: [PATCH 1/2] git, gitweb: Fix git-instaweb * Make the build system embed the correct path to gitweb into git-instaweb * Move gitweb fixups to the git expression, to make sure that gitweb used by git-instaweb is functional * This will increase the closure size of git, but only with perlSupport --- .../git-and-tools/git/default.nix | 17 ++++++++++++++--- .../git-and-tools/gitweb/default.nix | 13 +------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkgs/applications/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix index 46e88b1e0fc4..9c405d0aba8c 100644 --- a/pkgs/applications/version-management/git-and-tools/git/default.nix +++ b/pkgs/applications/version-management/git-and-tools/git/default.nix @@ -14,6 +14,7 @@ , darwin , withLibsecret ? false , pkgconfig, glib, libsecret +, gzip # needed at runtime by gitweb.cgi }: assert sendEmailSupport -> perlSupport; @@ -22,6 +23,8 @@ assert svnSupport -> perlSupport; let version = "2.19.2"; svn = subversionClient.override { perlBindings = perlSupport; }; + + gitwebPerlLibs = with perlPackages; [ CGI HTMLParser CGIFast FCGI FCGIProcManager HTMLTagCloud ]; in stdenv.mkDerivation { @@ -84,6 +87,7 @@ stdenv.mkDerivation { makeFlags = [ "prefix=\${out}" + "gitwebdir=\${gitweb}" # put in separate package for simpler maintenance "SHELL_PATH=${stdenv.shell}" ] ++ (if perlSupport then ["PERL_PATH=${perlPackages.perl}/bin/perl"] else ["NO_PERL=1"]) @@ -169,9 +173,6 @@ stdenv.mkDerivation { # HTTP(s) transports for pushing ln -s $out/libexec/git-core/git-http-backend $out/bin/git-http-backend '' + stdenv.lib.optionalString perlSupport '' - # put in separate package for simpler maintenance - mv $out/share/gitweb $gitweb/ - # wrap perl commands makeWrapper "$out/share/git/contrib/credential/netrc/git-credential-netrc" $out/bin/git-credential-netrc \ --set PERL5LIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}" @@ -185,6 +186,16 @@ stdenv.mkDerivation { --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}" wrapProgram $out/libexec/git-core/git-cvsexportcommit \ --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}" + + # 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'|" \ + $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/${perlPackages.perl.libPrefix}\";" \ + "$gitweb/gitweb.cgi" + done '' + (if svnSupport then '' diff --git a/pkgs/applications/version-management/git-and-tools/gitweb/default.nix b/pkgs/applications/version-management/git-and-tools/gitweb/default.nix index a98dd5bc5862..f165fa6b05ca 100644 --- a/pkgs/applications/version-management/git-and-tools/gitweb/default.nix +++ b/pkgs/applications/version-management/git-and-tools/gitweb/default.nix @@ -1,8 +1,7 @@ -{ stdenv, git, gzip, perlPackages, fetchFromGitHub +{ stdenv, git, fetchFromGitHub , gitwebTheme ? false }: let - gitwebPerlLibs = with perlPackages; [ CGI HTMLParser CGIFast FCGI FCGIProcManager HTMLTagCloud ]; gitwebThemeSrc = fetchFromGitHub { owner = "kogakure"; repo = "gitweb-theme"; @@ -18,16 +17,6 @@ in stdenv.mkDerivation { 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/${perlPackages.perl.libPrefix}\";" \ - "$out/gitweb.cgi" - done - ${stdenv.lib.optionalString gitwebTheme "cp ${gitwebThemeSrc}/* $out/static"} ''; From 047def418ee726a43b46bce6d93f26e2dd705cb4 Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Sun, 6 Jan 2019 16:09:20 +0300 Subject: [PATCH 2/2] git: Do not split gitweb output This partially reverts 9029ed933c69287c64a30d40b6b4f9f1ace7dd94 as `git-instaweb`, which comes with git, needs on gitweb and having them in separate outputs results in a cycle. --- .../git-and-tools/git/default.nix | 7 +++--- .../git-and-tools/gitweb/default.nix | 23 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkgs/applications/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix index 9c405d0aba8c..8be4dcc95c83 100644 --- a/pkgs/applications/version-management/git-and-tools/git/default.nix +++ b/pkgs/applications/version-management/git-and-tools/git/default.nix @@ -35,7 +35,7 @@ stdenv.mkDerivation { sha256 = "1scbggzghkzzfqg4ky3qh7h9w87c3zya4ls5disz7dbx56is7sgw"; }; - outputs = [ "out" ] ++ stdenv.lib.optional perlSupport "gitweb"; + outputs = [ "out" ]; hardeningDisable = [ "format" ]; @@ -87,7 +87,6 @@ stdenv.mkDerivation { makeFlags = [ "prefix=\${out}" - "gitwebdir=\${gitweb}" # put in separate package for simpler maintenance "SHELL_PATH=${stdenv.shell}" ] ++ (if perlSupport then ["PERL_PATH=${perlPackages.perl}/bin/perl"] else ["NO_PERL=1"]) @@ -190,11 +189,11 @@ stdenv.mkDerivation { # 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'|" \ - $gitweb/gitweb.cgi + $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/${perlPackages.perl.libPrefix}\";" \ - "$gitweb/gitweb.cgi" + "$out/share/gitweb/gitweb.cgi" done '' diff --git a/pkgs/applications/version-management/git-and-tools/gitweb/default.nix b/pkgs/applications/version-management/git-and-tools/gitweb/default.nix index f165fa6b05ca..afd90ba49690 100644 --- a/pkgs/applications/version-management/git-and-tools/gitweb/default.nix +++ b/pkgs/applications/version-management/git-and-tools/gitweb/default.nix @@ -1,4 +1,4 @@ -{ stdenv, git, fetchFromGitHub +{ stdenv, buildEnv, git, fetchFromGitHub , gitwebTheme ? false }: let @@ -6,19 +6,20 @@ let owner = "kogakure"; repo = "gitweb-theme"; rev = "049b88e664a359f8ec25dc6f531b7e2aa60dd1a2"; - sha256 = "0wksqma41z36dbv6w6iplkjfdm0ha3njp222fakyh4lismajr71p"; + extraPostFetch = '' + mkdir -p "$TMPDIR/gitwebTheme" + mv "$out"/* "$TMPDIR/gitwebTheme/" + mkdir "$out/static" + mv "$TMPDIR/gitwebTheme"/* "$out/static/" + ''; + sha256 = "17hypq6jvhy6zhh26lp3nyi52npfd5wy5752k6sq0shk4na2acqi"; }; -in stdenv.mkDerivation { +in buildEnv { name = "gitweb-${stdenv.lib.getVersion git}"; - src = git.gitweb; - - installPhase = '' - mkdir $out - mv * $out - - ${stdenv.lib.optionalString gitwebTheme "cp ${gitwebThemeSrc}/* $out/static"} - ''; + ignoreCollisions = true; + paths = stdenv.lib.optional gitwebTheme "${gitwebThemeSrc}" + ++ [ "${git}/share/gitweb" ]; meta = git.meta // { maintainers = with stdenv.lib.maintainers; [ gnidorah ];