about summary refs log tree commit diff
path: root/sys
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-04-15 16:20:30 +0000
committerAlyssa Ross <hi@alyssa.is>2020-04-15 16:41:52 +0000
commitb394434a89f25fe74aa2c43f376454921216ad80 (patch)
tree0c75c375b3aea92a30c818f54302dcc148d39c7a /sys
parent8feabbb6d405962225323759c2530e9d3651847d (diff)
downloadnixlib-b394434a89f25fe74aa2c43f376454921216ad80.tar
nixlib-b394434a89f25fe74aa2c43f376454921216ad80.tar.gz
nixlib-b394434a89f25fe74aa2c43f376454921216ad80.tar.bz2
nixlib-b394434a89f25fe74aa2c43f376454921216ad80.tar.lz
nixlib-b394434a89f25fe74aa2c43f376454921216ad80.tar.xz
nixlib-b394434a89f25fe74aa2c43f376454921216ad80.tar.zst
nixlib-b394434a89f25fe74aa2c43f376454921216ad80.zip
sys/atuin: add custom cgit CSS
Diffstat (limited to 'sys')
-rw-r--r--sys/atuin.nix133
1 files changed, 122 insertions, 11 deletions
diff --git a/sys/atuin.nix b/sys/atuin.nix
index c281722a4836..acf2c1972e78 100644
--- a/sys/atuin.nix
+++ b/sys/atuin.nix
@@ -158,17 +158,21 @@
         "git.qyliss.net" = {
           root = "${pkgs.cgit}/cgit";
 
-          locations."@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;
-          '';
+          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;
@@ -178,6 +182,7 @@
 
       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
@@ -223,6 +228,112 @@
 
         REDIRECT_STATUS   = "200";
       } // params));
+      cgitCss = pkgs.runCommand "cgit-extra.css" {
+        licenseHeader = ''
+          /*
+           * This program is free software: you can redistribute it and/or modify
+           * it under the terms of the GNU General Public License v2 as published
+           * by the Free Software Foundation.
+           *
+           * This program is distributed in the hope that it will be useful,
+           * but WITHOUT ANY WARRANTY; without even the implied warranty of
+           * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+           * GNU General Public License for more details.
+           *
+           * See <https://www.gnu.org/licenses/>.
+           */
+
+        '';
+
+        # Adapted from
+        # <https://git.causal.agency/src/plain/www/git.causal.agency/custom.css>,
+        # distributed as a Larger Work under a Secondary License,
+        # as permitted by the terms of the
+        # Mozilla Public License Version 2.0.
+        extraCss = ''
+          * { line-height: 1.25em; }
+
+          article {
+            font-family: sans-serif;
+            max-width: 70ch;
+            margin-left: auto;
+            margin-right: auto;
+          }
+
+          div#cgit {
+            margin: auto;
+            font-family: monospace;
+            -moz-tab-size: 4;
+            tab-size: 4;
+            display: table;
+          }
+
+          div#cgit table#header {
+            margin-left: auto;
+            margin-right: auto;
+          }
+          div#cgit table#header td.logo {
+            display: none;
+          }
+          div#cgit table#header td.main {
+            font-size: 1em;
+            font-weight: bold;
+          }
+          div#cgit table#header td.sub {
+            border-top: none;
+          }
+          div#cgit table.tabs {
+            margin-left: auto;
+            margin-right: auto;
+            border-bottom: none;
+          }
+          div#cgit div.content {
+            border-bottom: none;
+            min-width: 108ch;
+          }
+          div#cgit div.content div#summary {
+            display: table;
+            margin-left: auto;
+            margin-right: auto;
+          }
+          div#cgit table.list {
+            margin-left: auto;
+            margin-right: auto;
+          }
+          div#cgit table.list th a {
+            color: inherit;
+          }
+          div#cgit table.list tr:nth-child(even) {
+            background: inherit;
+          }
+          div#cgit table.list tr:hover {
+            background: inherit;
+          }
+          div#cgit table.list tr.nohover-highlight:hover:nth-child(even) {
+            background: inherit;
+          }
+          div#cgit table.list td:last-child {
+            width: 0;
+          }
+          div#cgit div.footer {
+            font-size: 1em;
+            margin-top: 0;
+          }
+
+          div#cgit table.blob td.linenumbers:nth-last-child(3) {
+            display: none;
+          }
+
+          div#cgit table.blob td.linenumbers a:target {
+            color: goldenrod;
+            text-decoration: underline;
+            outline: none;
+          }
+        '';
+        passAsFile = [ "licenseHeader" "extraCss" ];
+      } ''
+        cat $licenseHeaderPath ${pkgs.cgit}/cgit/cgit.css $extraCssPath > $out
+      '';
     in
       lib.mapAttrs (
         _: { forceSSL ? true, enableACME ? true, ... } @ args: