From 53d246c2adda06165b21c55a2d5a4dc867b66994 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 15 Nov 2025 00:22:34 +0100 Subject: add git shell scripts --- modules/git/default.nix | 7 +++++++ modules/git/git-shell-commands/desc | 6 ++++++ modules/git/git-shell-commands/help | 11 +++++++++++ modules/git/git-shell-commands/init | 9 +++++++++ modules/git/git-shell-commands/owner | 6 ++++++ modules/git/git-shell-commands/section | 6 ++++++ 6 files changed, 45 insertions(+) create mode 100755 modules/git/git-shell-commands/desc create mode 100755 modules/git/git-shell-commands/help create mode 100755 modules/git/git-shell-commands/init create mode 100755 modules/git/git-shell-commands/owner create mode 100755 modules/git/git-shell-commands/section diff --git a/modules/git/default.nix b/modules/git/default.nix index 465d859..e30e529 100644 --- a/modules/git/default.nix +++ b/modules/git/default.nix @@ -33,6 +33,7 @@ max-repodesc-length = 120; clone-url = "https://$HTTP_HOST/$CGIT_REPO_URL"; + readme = "README.adoc"; source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py"; # about-filter = "${pkgs.asciidoctor}" @@ -65,6 +66,12 @@ }; }; + system.activationScripts.setup-git-shell-commands.text = '' + if [[ ! -h "/var/lib/git/git-shell-commands" ]]; then + ln -s "${./git-shell-commands}" "/var/lib/git/git-shell-commands" + fi + ''; + services.nginx.virtualHosts = { "git.audron.dev" = { forceSSL = true; diff --git a/modules/git/git-shell-commands/desc b/modules/git/git-shell-commands/desc new file mode 100755 index 0000000..52cc8bb --- /dev/null +++ b/modules/git/git-shell-commands/desc @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +if [ -f "$1/config" ]; then + cd "$1" + git config cgit.desc "$2" +fi diff --git a/modules/git/git-shell-commands/help b/modules/git/git-shell-commands/help new file mode 100755 index 0000000..7572fe4 --- /dev/null +++ b/modules/git/git-shell-commands/help @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +echo "Commands:" +echo " init " +echo " Initialize a new bare repo, default branch is main" +echo " desc " +echo " Set repo description" +echo " owner " +echo " Set repo owner" +echo " section
" +echo " Set repo section" diff --git a/modules/git/git-shell-commands/init b/modules/git/git-shell-commands/init new file mode 100755 index 0000000..603b817 --- /dev/null +++ b/modules/git/git-shell-commands/init @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +REPO="$1" + +if [ ! -f "$REPO/config" ]; then + mkdir -p "$REPO" + cd "$REPO" + git init --bare --shared +fi diff --git a/modules/git/git-shell-commands/owner b/modules/git/git-shell-commands/owner new file mode 100755 index 0000000..d65fd02 --- /dev/null +++ b/modules/git/git-shell-commands/owner @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +if [ -f "$1/config" ]; then + cd "$1" + git config cgit.owner "$2" +fi diff --git a/modules/git/git-shell-commands/section b/modules/git/git-shell-commands/section new file mode 100755 index 0000000..b1a998e --- /dev/null +++ b/modules/git/git-shell-commands/section @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +if [ -f "$1/config" ]; then + cd "$1" + git config cgit.section "$2" +fi -- cgit v1.2.3