git.nix (2137B)
1 2 { extra, config, pkgs }: 3 let gitwebConf = pkgs.writeText "gitweb.conf" '' 4 # path to git projects (<project>.git) 5 $projectroot = "${extra.git.projectroot}"; 6 ''; 7 gitweb-wrapper = pkgs.writeScript "gitweb.cgi" '' 8 #!${pkgs.bash}/bin/bash 9 export PERL5LIB=$PERL5LIB:${with pkgs.perlPackages; pkgs.lib.makePerlPath [ CGI HTMLParser ]} 10 ${pkgs.perl}/bin/perl ${pkgs.git}/share/gitweb/gitweb.cgi 11 ''; 12 gitweb-theme = pkgs.fetchFromGitHub { 13 owner = "kogakure"; 14 repo = "gitweb-theme"; 15 rev = "4305b3551551c470339c24a6567b1ac9e642ae54"; 16 sha256 = "0gagy0jvqb3mc587b6yy8l9g5j5wqr2xlz128v6f01364cb7whmv"; 17 }; 18 giturl = "git.monster.cat"; 19 in 20 if config.services.fcgiwrap.enable then '' 21 server { 22 listen 80; 23 server_name ${giturl}; 24 25 location = / { 26 return 301 http://${giturl}/repos/; 27 } 28 29 location = /repos { 30 return 301 http://${giturl}/repos/; 31 } 32 33 location / { 34 # fcgiwrap is set up to listen on this host:port 35 fastcgi_pass unix:${config.services.fcgiwrap.socketAddress}; 36 include ${pkgs.nginx}/conf/fastcgi_params; 37 fastcgi_param SCRIPT_FILENAME ${pkgs.git}/bin/git-http-backend; 38 39 client_max_body_size 0; 40 41 # export all repositories under GIT_PROJECT_ROOT 42 43 fastcgi_param GIT_HTTP_EXPORT_ALL ""; 44 fastcgi_param GIT_PROJECT_ROOT ${extra.git.projectroot}; 45 fastcgi_param PATH_INFO $uri; 46 } 47 48 location /repos/static { 49 alias ${gitweb-theme}; 50 } 51 52 location /add-repo { 53 include ${pkgs.nginx}/conf/fastcgi_params; 54 gzip off; 55 56 fastcgi_param SCRIPT_FILENAME /var/git/mkrepod; 57 fastcgi_pass unix:${config.services.fcgiwrap.socketAddress}; 58 } 59 60 location /repos { 61 include ${pkgs.nginx}/conf/fastcgi_params; 62 gzip off; 63 64 fastcgi_param GITWEB_CONFIG ${gitwebConf}; 65 fastcgi_param SCRIPT_FILENAME ${gitweb-wrapper}; 66 fastcgi_pass unix:${config.services.fcgiwrap.socketAddress}; 67 } 68 69 } 70 '' else ""