Created
August 16, 2020 22:43
-
-
Save telent/b3cddb5b69d1206cb130bbff56b4d5e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, ... }: | |
let projectroot = "/home/git/"; # where are the repos on the disk? | |
subdir = "private-git"; # url path prefix | |
staticFilesPath = "cgit-static"; # url path to cgit's static assets | |
# /home/git/published-by-cgit contains the list of projects | |
# that cgit will show | |
cgitrc = pkgs.writeText "cgitrc" | |
'' | |
# default paths to static assets | |
css=/${staticFilesPath}/cgit.css | |
logo=/${staticFilesPath}/cgit.png | |
favicon=/${staticFilesPath}/favicon.ico | |
snapshots=tar.gz | |
project-list=${projectroot}/published-by-cgit | |
scan-path=${projectroot} | |
''; | |
in { | |
config.services.fcgiwrap.enable = true; | |
config.services.nginx = { | |
virtualHosts."_" = { | |
locations."/${staticFilesPath}/" = { | |
# don't be confused, alias and root are different things | |
# in nginx, and root is probably the wrong one when you're | |
# not at the root of the virtual host | |
extraConfig = '' | |
alias ${pkgs.cgit}/cgit/; | |
''; | |
}; | |
locations."/${subdir}/" = { | |
extraConfig = '' | |
include ${pkgs.nginx}/conf/fastcgi_params; | |
# Incoming request might be for "/private-git/repo.git/foo/". | |
# This directs nginx to split that string into | |
# "/private-git/" and "repo.git/foo/" | |
# and put the second part in $fastcgi_path_info, | |
# which we can then pass to fastcgi as PATH_INFO. whoo. | |
fastcgi_split_path_info ^(/${subdir}/)(.*)$; | |
fastcgi_param CGIT_CONFIG ${cgitrc}; | |
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param QUERY_STRING $query_string; | |
fastcgi_pass unix:/run/fcgiwrap.sock; | |
''; | |
}; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment