diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-01-02 08:54:18 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-01-02 10:26:18 +0000 |
commit | 7b89d60ddb6bca484bfa3358ddd3dd1c8239252a (patch) | |
tree | 4fe20b250b193a1e67a19dd7fb517489c9e7995c /sys | |
parent | 3dd73a10335d5e5d82004c19a3ed1ee2744d9fd0 (diff) | |
download | nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.tar nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.tar.gz nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.tar.bz2 nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.tar.lz nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.tar.xz nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.tar.zst nixlib-7b89d60ddb6bca484bfa3358ddd3dd1c8239252a.zip |
modules/cgit: init
This will make it easier to move things out of the big nginx configuration in atuin.nix, and puts all the fiddly nginx setup for cgit in one place.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/atuin.nix | 219 |
1 files changed, 77 insertions, 142 deletions
diff --git a/sys/atuin.nix b/sys/atuin.nix index b8cb19427edf..3902eb954182 100644 --- a/sys/atuin.nix +++ b/sys/atuin.nix @@ -5,6 +5,7 @@ ../modules/server ../modules/server/dns ../modules/server/irc + ../modules/server/cgit ../modules/server/ftp ../modules/server/nginx ../modules/server/tor @@ -136,6 +137,82 @@ users.groups.tls.members = [ "nginx" ]; users.users.qyliss.home = "/home/qyliss"; + services.cgit.instances.qyliss = { + vhost = "git.qyliss.net"; + config = pkgs.writeText "cgit.conf" '' + clone-prefix=https://git.qyliss.net + css=/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 + remove-suffix=1 + root-desc=Alyssa Ross's personal Git repositories + root-title=git.qyliss.net + snapshots=all + about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh + source-filter=${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py + virtual-root=/ + + scan-path=/home/qyliss/git + ''; + }; + + services.cgit.instances.spectrum = { + vhost = "spectrum-os.org"; + path = "/git"; + config = + let + cgitFooter = pkgs.writeText "cgit-footer.html" '' + <div class="footer">software for Ⓐutonomy</div> + ''; + + 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> + ''; + in + 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 + snapshots=all + 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 + ''; + }; services.nginx.virtualHosts = let @@ -148,35 +225,8 @@ "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; - ''; - }; - - "= /lists/archives/public-inbox.css".alias = publicInboxCss.outPath; "/lists/archives".proxyPass = "http://unix:/run/public-inbox-httpd.sock:/lists/archives"; @@ -194,93 +244,12 @@ }; "git.qyliss.net" = { - root = "${pkgs.cgit}/cgit"; - locations = { "= /cgit.css".alias = cgitCss.outPath; - - "@cgit".extraConfig = '' - ${overrideFastcgiParams { - CGIT_CONFIG = cgitConfig; - SCRIPT_FILENAME = "$document_root/cgit.cgi"; - PATH_INFO = "$uri"; - QUERY_STRING = "$args"; - HTTP_HOST = "$server_name"; - }} - - fastcgi_pass unix:/run/fcgiwrap.sock; - ''; }; - - extraConfig = '' - try_files $uri @cgit; - ''; }; }; - cgitConfig = pkgs.writeText "cgit.conf" '' - clone-prefix=https://git.qyliss.net - css=/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 - remove-suffix=1 - root-desc=Alyssa Ross's personal Git repositories - root-title=git.qyliss.net - snapshots=all - about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh - source-filter=${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py - virtual-root=/ - - scan-path=/home/qyliss/git - ''; - - overrideFastcgiParams = with lib; params: concatStrings (mapAttrsToList (n: v: '' - fastcgi_param ${n} ${if v == "" then ''""'' else v}; - '') ({ - SCRIPT_FILENAME = "$document_root$fastcgi_script_name"; - QUERY_STRING = "$query_string"; - REQUEST_METHOD = "$request_method"; - CONTENT_TYPE = "$content_type"; - CONTENT_LENGTH = "$content_length"; - - SCRIPT_NAME = "$fastcgi_script_name"; - REQUEST_URI = "$request_uri"; - DOCUMENT_URI = "$document_uri"; - DOCUMENT_ROOT = "$document_root"; - SERVER_PROTOCOL = "$server_protocol"; - REQUEST_SCHEME = "$scheme"; - HTTPS = "$https if_not_empty"; - - GATEWAY_INTERFACE = "CGI/1.1"; - SERVER_SOFTWARE = "nginx/$nginx_version"; - - REMOTE_ADDR = "$remote_addr"; - REMOTE_PORT = "$remote_port"; - SERVER_ADDR = "$server_addr"; - SERVER_PORT = "$server_port"; - SERVER_NAME = "$server_name"; - - 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> - ''; - publicInboxCss = pkgs.runCommand "216light.css" {} '' unpackFile ${pkgs.public-inbox.src} cp */contrib/css/216light.css $out @@ -397,40 +366,6 @@ } '' 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 - snapshots=all - 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: |