diff options
-rw-r--r-- | sys/atuin.nix | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/sys/atuin.nix b/sys/atuin.nix index 66f0831a4716..8637011593c3 100644 --- a/sys/atuin.nix +++ b/sys/atuin.nix @@ -144,7 +144,39 @@ "spectrumos.org".locations."/".return = "301 https://spectrum-os.org/"; "www.spectrum-os.org".locations."/".return = "301 https://spectrum-os.org/"; "www.spectrumos.org".locations."/".return = "301 https://spectrum-os.org/"; - "spectrum-os.org".locations."/".root = "/home/spectrum/www"; + + "spectrum-os.org".locations = { + "/".root = "/home/spectrum/www"; + + "= /git".return = "301 /git/"; + + "= /git/cgit.css".alias = cgitCss.outPath; + + "/git/" = { + alias = "${pkgs.cgit}/cgit/"; + tryFiles = "$uri @spectrum-cgit"; + }; + + "@spectrum-cgit" = { + root = "${pkgs.cgit}/cgit"; + + extraConfig = '' + fastcgi_split_path_info ^(/git/)(.*)$; + + ${overrideFastcgiParams { + CGIT_CONFIG = spectrumCgitConfig; + SCRIPT_FILENAME = "$document_root/cgit.cgi"; + SCRIPT_NAME = "$fastcgi_script_name"; + PATH_INFO = "$fastcgi_path_info"; + QUERY_STRING = "$args"; + HTTP_HOST = "$server_name"; + }} + + fastcgi_pass unix:/run/fcgiwrap.sock; + ''; + }; + + }; default = { serverName = null; @@ -229,6 +261,20 @@ REDIRECT_STATUS = "200"; } // params)); + + spectrumReadme = pkgs.writeText "about.html" '' + <article> + + <h1>Contributing to Spectrum</h1> + + <p> + Want to contribute to Spectrum? We'd love to have you. + Have a look at the <a href="/contributing.html">online + documentation</a>. + + </article> + ''; + cgitCss = pkgs.runCommand "cgit-extra.css" { licenseHeader = '' /* @@ -335,6 +381,39 @@ } '' cat $licenseHeaderPath ${pkgs.cgit}/cgit/cgit.css $extraCssPath > $out ''; + + cgitFooter = pkgs.writeText "cgit-footer.html" '' + <div class="footer">software for Ⓐutonomy</div> + ''; + + spectrumCgitConfig = pkgs.writeText "cgit.conf" '' + clone-prefix=https://spectrum-os.org/git + css=/git/cgit.css + enable-blame=1 + enable-commit-graph=1 + enable-follow-links=1 + enable-git-config=1 + enable-index-owner=0 + enable-log-filecount=1 + enable-log-linecount=1 + footer=${cgitFooter} + remove-suffix=1 + root-desc=Web interface for Spectrum source code + root-readme=${spectrumReadme} + root-title=Spectrum Git Repository Browser + about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh + source-filter=${pkgs.runCommandNoCC "source-filter.py" { + nativeBuildInputs = with pkgs; with python3.pkgs; [ wrapPython ]; + } '' + mkdir -p $out/bin + sed s/pastie/friendly/g >$out/bin/syntax-highlighting.py \ + <${pkgs.cgit}/lib/cgit/filters/.syntax-highlighting.py-wrapped + chmod +x $out/bin/syntax-highlighting.py + wrapPythonPrograms + ''}/bin/syntax-highlighting.py + + scan-path=/home/spectrum/git + ''; in lib.mapAttrs ( _: { forceSSL ? true, enableACME ? true, ... } @ args: |