aboutsummaryrefslogtreecommitdiff
path: root/modules/services/nixos/cgit/gitShellCommands.nix
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-02-25 13:47:47 -0600
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-02-25 13:47:47 -0600
commitfbecc291f4d3a5f93e487526701d43a494b88ece (patch)
tree8af9070313d274ed5ef282f395b9163df3364eb2 /modules/services/nixos/cgit/gitShellCommands.nix
parentd2747292dff98c64b974bdfe6b46bc62252298de (diff)
changes
Diffstat (limited to 'modules/services/nixos/cgit/gitShellCommands.nix')
-rw-r--r--modules/services/nixos/cgit/gitShellCommands.nix77
1 files changed, 42 insertions, 35 deletions
diff --git a/modules/services/nixos/cgit/gitShellCommands.nix b/modules/services/nixos/cgit/gitShellCommands.nix
index e99f9f2..18c6e19 100644
--- a/modules/services/nixos/cgit/gitShellCommands.nix
+++ b/modules/services/nixos/cgit/gitShellCommands.nix
@@ -1,43 +1,50 @@
{
- hjem.users."git".files = {
- "git-shell-commands/set-description" = {
- executable = true;
- text = ''
- #!/usr/bin/env bash
- set -euo pipefail
- repo="$1"
- desc="$2"
- base="/var/lib/cgit"
- repo_path="$base/$repo"
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.collinux.services.cgit;
+in
+ lib.mkIf cfg.enable {
+ hjem.users."git".files = {
+ "git-shell-commands/set-description" = {
+ executable = true;
+ text = ''
+ #!/usr/bin/env bash
+ set -euo pipefail
+ repo="$1"
+ desc="$2"
+ base="/var/lib/cgit"
+ repo_path="$base/$repo"
- test -d "$repo_path" || { echo "Repository does not exist"; exit 1; }
+ test -d "$repo_path" || { echo "Repository does not exist"; exit 1; }
- # Prevent path traversal
- real=$(realpath "$repo_path")
- if [[ "$real" != "$base/"* ]]; then
- echo "Invalid path"
- exit 1
- fi
+ # Prevent path traversal
+ real=$(realpath "$repo_path")
+ if [[ "$real" != "$base/"* ]]; then
+ echo "Invalid path"
+ exit 1
+ fi
- echo "$desc" | head -n 1 > "$repo_path/description"
+ echo "$desc" | head -n 1 > "$repo_path/description"
- echo "Description updated for '$repo'"
- '';
- };
- "git-shell-commands/create-repo" = {
- executable = true;
- text = ''
- #!/usr/bin/env bash
- set -euo pipefail
- repo="$1"
- base="/var/lib/cgit"
- repo_path="$base/$repo"
+ echo "Description updated for '$repo'"
+ '';
+ };
+ "git-shell-commands/create-repo" = {
+ executable = true;
+ text = ''
+ #!/usr/bin/env bash
+ set -euo pipefail
+ repo="$1"
+ base="/var/lib/cgit"
+ repo_path="$base/$repo"
- test -d "$repo_path" && { echo "Repository already exists."; exit 1; }
+ test -d "$repo_path" && { echo "Repository already exists."; exit 1; }
- git init --bare "$repo_path"
- echo "Repository '$repo' created"
- '';
+ git init --bare "$repo_path"
+ echo "Repository '$repo' created"
+ '';
+ };
};
- };
-}
+ }