{ pkgs, lib, ... }: let cgit-org2html = pkgs.writeShellScriptBin "org2html" '' ${pkgs.pandoc}/bin/pandoc \ --from org \ --to html5 \ --sandbox=true \ --html-q-tags \ --ascii \ --standalone \ --wrap=auto \ --embed-resources \ -M document-css=false ''; about-formatting = pkgs.writeShellScriptBin "about-formatting" '' cd "${pkgs.cgit}/lib/cgit/filters/html-converters" case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in *.markdown|*.mdown|*.md|*.mkd) exec ./md2html; ;; *.rst) exec ./rst2html; ;; *.[1-9]) exec ./man2html; ;; *.htm|*.html) exec cat; ;; *.txt) exec ./txt2html; ;; *.org) exec ${cgit-org2html}/bin/org2html; ;; esac ''; in { services.gitolite = { enable = true; adminPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINBkozy+X96u5ciX766bJ/AyQ3xm1tXZTIr5+4PVFZFi"; user = "git"; group = "git"; extraGitoliteRc = '' # Make dirs/files group readable, needed for webserver/cgit. (Default # setting is 0077.) $RC{UMASK} = 0027; $RC{GIT_CONFIG_KEYS} = 'cgit.desc cgit.hide cgit.ignore cgit.owner cgit.section'; $RC{LOCAL_CODE} = "$rc{GL_ADMIN_BASE}/local"; push( @{$RC{ENABLE}}, 'symbolic-ref' ); ''; }; # let's make sure the default branch is `main'. # NOTE: gitolite-admin.git default branch needs to be named master systemd.tmpfiles.rules = [ "C /var/lib/gitolite/.gitconfig - git git 0644 ${pkgs.writeText "gitolite-gitconfig" '' [init] defaultBranch = main ''}" ]; services.cgit.main = { enable = true; package = pkgs.cgit; user = "git"; group = "git"; nginx.virtualHost = "code.fcuny.net"; scanPath = "/var/lib/gitolite/repositories"; settings = { css = "/cgit.css"; logo = "/cgit.png"; favicon = "/favicon.ico"; robots = "noindex, nofollow"; readme = [ ":README.md" ":README.org" ]; project-list = "/var/lib/gitolite/projects.list"; about-filter = "${about-formatting}/bin/about-formatting"; source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py"; clone-url = (lib.concatStringsSep " " [ "https://code.fcuny.net/$CGIT_REPO_URL" ]); enable-log-filecount = 1; enable-log-linecount = 1; enable-git-config = 1; enable-blame = 1; enable-commit-graph = 1; enable-follow-links = 1; enable-index-owner = 0; enable-index-links = 1; enable-remote-branches = 1; enable-subject-links = 1; remove-suffix = 1; enable-tree-linenumbers = 1; max-atom-items = 108; max-commit-count = 250; max-repo-count = 500; repository-sort = "age"; snapshots = "tar.gz"; root-title = "¯\\_(ツ)_/¯"; root-desc = "source code of my various projects"; }; }; }