From 03b05e7ea5e094fd25275f0c549ef5b74d0284d6 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 22 Feb 2024 02:17:49 +0100 Subject: cgit: add default filters --- apps/cgit/module.nix | 58 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/apps/cgit/module.nix b/apps/cgit/module.nix index 106764b..593f8a5 100644 --- a/apps/cgit/module.nix +++ b/apps/cgit/module.nix @@ -1,16 +1,44 @@ { appConfig, config, lib, pkgs, ... }: -{ - services.cgit.default.enable = true; - services.cgit.default.nginx.virtualHost = appConfig.domain; - services.cgit.default.repos = lib.mapAttrs - (name: attrs: { - desc = attrs.description; - path = "/var/lib/git/${name}"; - }) - appConfig.repositories; - services.cgit.default.settings = appConfig.settings; - - users.users.git.isSystemUser = true; - users.users.git.home = "/var/lib/git"; - users.users.git.group = "nogroup"; -} +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"; + } +] -- cgit v1.2.3