Commit c95c7ec1412a
Changed files (2)
systems
kerkouane
docs/git-post-receive-hooks.md
@@ -57,8 +57,12 @@ The `git-notify@.service` template:
- Sends ntfy notification with appropriate emoji and priority
**Notification format:**
-- Success: ✅ Git <job> Success: <repo>
-- Failure: ❌ Git <job> Failed: <repo> (with high priority)
+- Success: ✅ Git <job> Success: <repo> (duration)
+- Failure: ❌ Git <job> Failed: <repo> (after duration) (with high priority)
+
+**Duration display:**
+- Less than 60 seconds: "42s"
+- 60 seconds or more: "1m 23s"
**Unit name format:** `git-<job>-<repo>-<timestamp>`
- Example: `git-gitmal-myrepo-20260107-143022`
@@ -78,7 +82,15 @@ The `git-notify@.service` template:
chmod +x hooks/post-receive
```
-3. **Customize if needed** (the example works for gitmal generation out of the box)
+3. **Configure the theme (optional):**
+
+ Edit `hooks/post-receive` and set the theme at the top:
+ ```bash
+ # Configuration
+ GITMAL_THEME="github-dark" # Options: github-dark, github-light, dark, light, auto
+ ```
+
+4. **Customize if needed** (the example works for gitmal generation out of the box)
### Example Post-Receive Hook
@@ -86,23 +98,26 @@ The `git-notify@.service` template:
#!/usr/bin/env bash
set -euo pipefail
+# Configuration
+GITMAL_THEME="github-dark" # Options: github-dark, github-light, dark, light, auto
+
REPO_PATH="$(pwd)"
REPO_NAME=$(basename "$REPO_PATH" .git)
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
UNIT_NAME="git-gitmal-${REPO_NAME}-${TIMESTAMP}"
-echo "Queuing gitmal generation for $REPO_NAME..."
+echo "Queuing gitmal generation for $REPO_NAME with theme: $GITMAL_THEME..."
# Run gitmal generation in background with systemd-run
sudo systemd-run \
--unit="$UNIT_NAME" \
--description="Gitmal generation for $REPO_NAME" \
- --property="OnSuccess=git-notify@%n.service" \
- --property="OnFailure=git-notify@%n.service" \
+ --property="OnSuccess=git-notify@${UNIT_NAME}.service" \
+ --property="OnFailure=git-notify@${UNIT_NAME}.service" \
--property="User=vincent" \
--property="Group=users" \
--working-directory="$REPO_PATH" \
- /etc/git-hooks/generate-gitmal.sh "$REPO_PATH"
+ /etc/git-hooks/generate-gitmal.sh "$REPO_PATH" "$GITMAL_THEME"
echo "✓ Gitmal generation queued as: $UNIT_NAME"
echo " View status: systemctl status $UNIT_NAME"
@@ -131,6 +146,32 @@ systemctl list-units 'git-*'
journalctl -f -u git-gitmal-myrepo-20260107-143022
```
+## Customizing Gitmal Theme
+
+Gitmal supports different themes that can be configured per-repository:
+
+**Available themes:**
+- `github-dark` - GitHub dark theme (default)
+- `github-light` - GitHub light theme
+- `dark` - Dark theme
+- `light` - Light theme
+- `auto` - Automatically switch based on system preference
+
+**To set the theme for a repository:**
+
+Edit the repository's `hooks/post-receive` file:
+```bash
+# Configuration
+GITMAL_THEME="github-light" # Change to your preferred theme
+```
+
+The theme is passed as the second parameter to `generate-gitmal.sh`:
+```bash
+/etc/git-hooks/generate-gitmal.sh "$REPO_PATH" "$GITMAL_THEME"
+```
+
+**Default theme:** If no theme is specified, the system defaults to `github-dark`.
+
## Extending the System
### Creating Custom Build Scripts
@@ -462,5 +503,5 @@ done
---
-**Last updated:** 2026-01-07
+**Last updated:** 2026-01-07 (v2: Added execution time tracking and theme selection)
**Author:** Vincent Demeester (with Claude Code assistance)
systems/kerkouane/extra.nix
@@ -99,6 +99,24 @@ in
RESULT=$(${pkgs.systemd}/bin/systemctl show -p Result --value "$UNIT_NAME")
EXIT_CODE=$(${pkgs.systemd}/bin/systemctl show -p ExecMainStatus --value "$UNIT_NAME")
+ # Get execution timestamps (in microseconds since epoch)
+ START_TIME=$(${pkgs.systemd}/bin/systemctl show -p ExecMainStartTimestamp --value "$UNIT_NAME")
+ EXIT_TIME=$(${pkgs.systemd}/bin/systemctl show -p ExecMainExitTimestamp --value "$UNIT_NAME")
+
+ # Calculate duration in seconds
+ START_EPOCH=$(${pkgs.coreutils}/bin/date -d "$START_TIME" +%s 2>/dev/null || echo "0")
+ EXIT_EPOCH=$(${pkgs.coreutils}/bin/date -d "$EXIT_TIME" +%s 2>/dev/null || echo "0")
+ DURATION=$((EXIT_EPOCH - START_EPOCH))
+
+ # Format duration as human-readable
+ if [ "$DURATION" -ge 60 ]; then
+ MINUTES=$((DURATION / 60))
+ SECONDS=$((DURATION % 60))
+ DURATION_STR="''${MINUTES}m ''${SECONDS}s"
+ else
+ DURATION_STR="''${DURATION}s"
+ fi
+
# Parse unit name to extract job type and repo
# Format: git-<job>-<repo>-<timestamp>
JOB_TYPE=$(echo "$UNIT_NAME" | cut -d'-' -f2)
@@ -109,20 +127,20 @@ in
-H "Authorization: Bearer $(${pkgs.coreutils}/bin/tr -d '\n' < ${
config.age.secrets."ntfy-token".path
})" \
- -H "Title: ✅ Git $JOB_TYPE Success: $REPO" \
+ -H "Title: ✅ Git $JOB_TYPE Success: $REPO ($DURATION_STR)" \
-H "Tags: white_check_mark,git,$JOB_TYPE" \
-H "Priority: default" \
- -d "Job $UNIT_NAME completed successfully (exit code: $EXIT_CODE)" \
+ -d "Job $UNIT_NAME completed successfully in $DURATION_STR (exit code: $EXIT_CODE)" \
"https://ntfy.sbr.pm/git-builds" || true
else
${pkgs.curl}/bin/curl -s \
-H "Authorization: Bearer $(${pkgs.coreutils}/bin/tr -d '\n' < ${
config.age.secrets."ntfy-token".path
})" \
- -H "Title: ❌ Git $JOB_TYPE Failed: $REPO" \
+ -H "Title: ❌ Git $JOB_TYPE Failed: $REPO (after $DURATION_STR)" \
-H "Priority: high" \
-H "Tags: x,git,$JOB_TYPE,warning" \
- -d "Job $UNIT_NAME failed (exit code: $EXIT_CODE). Check logs: journalctl -u $UNIT_NAME" \
+ -d "Job $UNIT_NAME failed after $DURATION_STR (exit code: $EXIT_CODE). Check logs: journalctl -u $UNIT_NAME" \
"https://ntfy.sbr.pm/git-builds" || true
fi
''} %i";
@@ -136,16 +154,18 @@ in
set -euo pipefail
REPO_PATH="$1"
+ THEME="''${2:-github-dark}" # Default to 'github-dark' theme if not specified
REPO_NAME=$(basename "$REPO_PATH" .git)
OUTPUT_DIR="/home/vincent/git/public/$REPO_NAME"
echo "Generating gitmal for repository: $REPO_NAME"
echo "Repository path: $REPO_PATH"
echo "Output directory: $OUTPUT_DIR"
+ echo "Theme: $THEME"
# Generate static site with gitmal
cd "$REPO_PATH"
- ${pkgs.gitmal}/bin/gitmal --output "$OUTPUT_DIR"
+ ${pkgs.gitmal}/bin/gitmal --output "$OUTPUT_DIR" --theme "$THEME"
echo "Gitmal generation complete: $OUTPUT_DIR"
'';
@@ -164,12 +184,15 @@ in
set -euo pipefail
+ # Configuration
+ GITMAL_THEME="github-dark" # Options: github-dark, github-light, dark, light, auto
+
REPO_PATH="$(pwd)"
REPO_NAME=$(basename "$REPO_PATH" .git)
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
UNIT_NAME="git-gitmal-''${REPO_NAME}-''${TIMESTAMP}"
- echo "Queuing gitmal generation for $REPO_NAME..."
+ echo "Queuing gitmal generation for $REPO_NAME with theme: $GITMAL_THEME..."
# Run gitmal generation in background with systemd-run
# OnSuccess/OnFailure will trigger git-notify@.service for notifications
@@ -182,7 +205,7 @@ in
--property="Group=users" \
--property="Environment=PATH=${pkgs.coreutils}/bin:${pkgs.git}/bin:${pkgs.gitmal}/bin" \
--working-directory="$REPO_PATH" \
- /etc/git-hooks/generate-gitmal.sh "$REPO_PATH"
+ /etc/git-hooks/generate-gitmal.sh "$REPO_PATH" "$GITMAL_THEME"
echo "✓ Gitmal generation queued as: $UNIT_NAME"
echo " View status: systemctl status $UNIT_NAME"