about summary refs log tree commit diff
path: root/modules/server/spectrum/cgit/default.nix
blob: f6df47872789e87bd61c51782e83929c48edd74a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ 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-pink}/lib/cgit/filters/.syntax-highlighting.py-wrapped
    chmod +x $out/bin/syntax-highlighting.py
    wrapPythonPrograms
  '';
in

{
  imports = [ ../../cgit ];

  services.cgit.instances.spectrum = {
    package = pkgs.cgit-pink;
    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
      favicon=https://spectrum-os.org/logo/logo_html.svg
      footer=${cgitFooter}
      logo=
      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-pink}/lib/cgit/filters/about-formatting.sh
      source-filter=${sourceFilter}/bin/syntax-highlighting.py

      scan-path=/home/spectrum/git
    '';
  };
}