aboutsummaryrefslogtreecommitdiff
path: root/modules/cgit/default.nix
blob: 08784feafa18778c3133940fa81a5b24c23d10d2 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{ config, pkgs, lib, ... }:
let
  cgitWithAssets = pkgs.cgit.overrideAttrs (old: {
    pname   = "cgit-with-assets";

    postInstall = (old.postInstall or "") + ''
      # overwrite the stock files that the module aliases
      install -Dm444 ${./static/cgit.css}     $out/cgit/cgit.css
      install -Dm444 ${./static/logo.png}     $out/cgit/cgit.png   # keep the name!
      install -Dm444 ${./static/favicon.png}  $out/cgit/favicon.ico
    '';
  });
in {
  services = {
    cgit."code" = {
      enable = true;
      scanPath = "/srv/git";
      package = cgitWithAssets;
      
      settings = {
        cache-size = 0;
        cache-scanrc-ttl = 0;
        enable-log-filecount = 1;
        enable-log-linecount = 1;
        enable-git-config = 1;

        localtime = 1;

        noplainemail = 1;

        root-title = "code.aethrvmn.gr";
        root-desc = "αpothēke of aethrvmn";
        clone-url = "https://code.aethrvmn.gr/$CGIT_REPO_URL";

        logo-link = "https://aethrvmn.gr/";

        about-filter  = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
        source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
      };

      nginx.virtualHost = "code.internal";
    };
  };

  users = {
    groups.git = { };

    users = {
      git = {
        isSystemUser = true;
        description = "aethrvmn";
        group = "git";
        home = "/srv/git";
        homeMode = "0755";
        createHome = true;
        shell = "${pkgs.git}/bin/git-shell";

        openssh.authorizedKeys.keys = [
          "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFTRmMBlTFJbOWQBLI9XS2HMdUSlsAcaQ6vWjLpfweEo aethrvmn@apotheke.earth"
        ];
      };

      cgit = {
        isSystemUser = true;
        extraGroups = [ "git" ];
      };
    };
  };

  systemd = {
    tmpfiles.rules = [
      # type path     mode uid gid age target
      "L /srv/git/static - git git - /home/aethrvmn/.nix/modules/server/cgit/static"
    ];
  };
}
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.