about summary refs log tree commit diff stats
path: root/modules/common/hooks
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/common/hooks/default.nix17
-rwxr-xr-xmodules/common/hooks/scripts/sync-git-repo.sh23
2 files changed, 40 insertions, 0 deletions
diff --git a/modules/common/hooks/default.nix b/modules/common/hooks/default.nix
new file mode 100644
index 00000000..5b694039
--- /dev/null
+++ b/modules/common/hooks/default.nix
@@ -0,0 +1,17 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+  pkgs,
+  lib,
+  config,
+}: {
+  sync-git-repos = config.lib.taskwarrior.mkHook "on-add" [pkgs.git] ./scripts/sync-git-repo.sh;
+  sync-git-repos-mod = config.lib.taskwarrior.mkHook "on-modify" [pkgs.git] ./scripts/sync-git-repo.sh;
+}
diff --git a/modules/common/hooks/scripts/sync-git-repo.sh b/modules/common/hooks/scripts/sync-git-repo.sh
new file mode 100755
index 00000000..fe0d0085
--- /dev/null
+++ b/modules/common/hooks/scripts/sync-git-repo.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env sh
+
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+task_data="$(task _get rc.data.location)"
+[ "$task_data" ] || die "Taskwarrior should have a location set"
+
+cd "$task_data" || die "(BUG?): Your data.location path is not accessable"
+
+[ -d ./.git/ ] || git init
+
+git add .
+git commit --message="chore: Update" --no-gpg-sign
+
+# vim: ft=sh