aboutsummaryrefslogtreecommitdiffstats
path: root/apps/cgit/module.nix
blob: 593f8a598b0c09e4916f60485a59f890e6bcbade (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
{ appConfig, config, lib, pkgs, ... }:
lib.mkMerge [
  {
    services.cgit.default.enable = true;
    services.cgit.default.nginx.virtualHost = appConfig.domain;
    # XXX https://github.com/NixOS/nixpkgs/issues/290524
    services.cgit.default.package = pkgs.symlinkJoin {
      name = "cgit";
      paths = [
        pkgs.cgit
        (pkgs.luajit.withPackages (luaPackages: [ luaPackages.luaossl ]))
        (pkgs.runCommandLocal "cgit-lua-packages" { } ''
          mkdir -p $out/cgit
          ln -s ../lib $out/cgit/lib
          ln -s ../share $out/cgit/share
        ''
        )
      ];
    };
    services.cgit.default.settings = appConfig.settings;
  }
  {
    services.cgit.default.settings.about-filter = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
    services.cgit.default.settings.commit-filter = "${pkgs.cgit}/lib/cgit/filters/commit-links.sh";
    services.cgit.default.settings.email-filter = "lua:${pkgs.cgit}/lib/cgit/filters/email-libravatar.lua";
    services.cgit.default.settings.source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
  }
  {
    services.cgit.default.repos = lib.mapAttrs
      (name: attrs: {
        defbranch = "main";
        desc = attrs.description;
        #owner = "aforemny";
        path = "/var/lib/git/${name}";
        readme = "main:README.md";
      })
      appConfig.repositories;
  }
  {
    users.users.git.isSystemUser = true;
    users.users.git.home = "/var/lib/git";
    users.users.git.group = "nogroup";
  }
]