diff options
-rw-r--r-- | modules/git/default.nix | 63 | ||||
-rw-r--r-- | modules/nginx.nix | 1 |
2 files changed, 46 insertions, 18 deletions
diff --git a/modules/git/default.nix b/modules/git/default.nix index 909bc2b..eb0021d 100644 --- a/modules/git/default.nix +++ b/modules/git/default.nix @@ -195,21 +195,18 @@ in # FIXME Plausible, go-import, custom favicon, etc. nixfiles.modules.nginx = { enable = true; - virtualHosts.${domain}.locations = { - "/".extraConfig = mkOrder 5000 '' - ${libNginx.config.appendHead [ - ''<meta name="go-import" content="$host$uri git https://$host$uri">'' - (libPlausible.htmlPlausibleScript { inherit (cfg.server) domain; }) - ]} - ''; - }; + virtualHosts.${domain}.locations = { }; }; services = { cgit.${domain} = { enable = true; + + # We make gitolite repos readable by the common group. group = "git"; + scanPath = "${config.services.gitolite.dataDir}/repositories"; + settings = { root-title = "cgit"; root-desc = "https://github.com/azahi"; @@ -223,17 +220,9 @@ in enable-git-config = true; enable-gitweb-owner = true; remove-suffix = true; + + logo = "/logo.gif"; }; - extraConfig = '' - readme=:README - readme=:README.md - readme=:README.org - readme=:README.txt - readme=:readme - readme=:readme.md - readme=:readme.org - readme=:readme.txt - ''; }; gitolite = { @@ -252,6 +241,44 @@ in $RC{GIT_CONFIG_KEYS} = '.*'; ''; }; + + nginx.virtualHosts.${domain}.locations = + let + extraHead = '' + ${libNginx.config.appendHead [ + ''<meta name="go-import" content="$host$uri git https://$host$uri">'' + (libPlausible.htmlPlausibleScript { inherit (cfg.server) domain; }) + ]} + ''; + in + { + "/" = { + extraConfig = mkBefore extraHead; + fastcgiParams.HTTP_ACCEPT_ENCODING = ""; + }; + "~ /.+/(info/refs|git-upload-pack)" = { + extraConfig = mkBefore extraHead; + fastcgiParams.HTTP_ACCEPT_ENCODING = ""; + }; + "= /logo.gif".alias = "${./logo.gif}"; + "= /favicon.ico" = { + alias = "${./favicon.ico}"; + extraConfig = mkForce ""; + }; + "= /cgit.css" = { + alias = pkgs.writeText "cgit.css" '' + ${readFile "${package}/cgit/cgit.css"} + div#cgit { + font-family: ${ + concatMapStringsSep ", " (f: ''"${f}"'') config.fonts.fontconfig.defaultFonts.monospace + }, monospace !important; + -moz-tab-size: 2 !important; + tab-size: 2 !important; + } + ''; + extraConfig = mkForce ""; + }; + }; }; } )) diff --git a/modules/nginx.nix b/modules/nginx.nix index b912e22..2ac6d1b 100644 --- a/modules/nginx.nix +++ b/modules/nginx.nix @@ -34,6 +34,7 @@ in } access_log off; ''; + # FIXME This stopped working. appendHead = text: '' sub_filter '</head>' '${lib.concatStrings text}</head>'; sub_filter_once on; |