about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-01-02 09:07:35 +0000
committerAlyssa Ross <hi@alyssa.is>2021-01-02 10:26:19 +0000
commit8b23c50a54ad5028d72edef8ae39e5153b54c3bf (patch)
tree6764ec9b2d8171f31ab5bf5f13a35d48266dd22e /modules
parent7b89d60ddb6bca484bfa3358ddd3dd1c8239252a (diff)
downloadnixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.tar
nixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.tar.gz
nixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.tar.bz2
nixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.tar.lz
nixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.tar.xz
nixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.tar.zst
nixlib-8b23c50a54ad5028d72edef8ae39e5153b54c3bf.zip
modules/spectrum/cgit: init
It's very good to finally have this out of sys/atuin.nix.
Diffstat (limited to 'modules')
-rw-r--r--modules/server/spectrum/cgit/default.nix60
-rw-r--r--modules/server/spectrum/default.nix2
2 files changed, 61 insertions, 1 deletions
diff --git a/modules/server/spectrum/cgit/default.nix b/modules/server/spectrum/cgit/default.nix
new file mode 100644
index 000000000000..c8a8eb3ac3a5
--- /dev/null
+++ b/modules/server/spectrum/cgit/default.nix
@@ -0,0 +1,60 @@
+{ pkgs, ... }:
+
+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>
+  '';
+
+  sourceFilter = pkgs.runCommandNoCC "source-filter" {
+    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
+  '';
+in
+
+{
+  imports = [ ../../cgit ];
+
+  services.cgit.instances.spectrum = {
+    vhost = "spectrum-os.org";
+    path = "/git";
+    config = 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=${sourceFilter}/bin/syntax-highlighting.py
+
+      scan-path=/home/spectrum/git
+    '';
+  };
+}
diff --git a/modules/server/spectrum/default.nix b/modules/server/spectrum/default.nix
index c4a8ac962a85..1c7eda3181a8 100644
--- a/modules/server/spectrum/default.nix
+++ b/modules/server/spectrum/default.nix
@@ -1,5 +1,5 @@
 { ... }:
 
 {
-  imports = [ ./nginx ./public-inbox ./tor ];
+  imports = [ ./cgit ./nginx ./public-inbox ./tor ];
 }