about summary refs log tree commit diff stats
path: root/modules/by-name/ta/taskwarrior/module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/ta/taskwarrior/module.nix')
-rw-r--r--modules/by-name/ta/taskwarrior/module.nix46
1 files changed, 39 insertions, 7 deletions
diff --git a/modules/by-name/ta/taskwarrior/module.nix b/modules/by-name/ta/taskwarrior/module.nix
index 4d015467..d757be90 100644
--- a/modules/by-name/ta/taskwarrior/module.nix
+++ b/modules/by-name/ta/taskwarrior/module.nix
@@ -1,3 +1,12 @@
+# 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>.
 {
   lib,
   config,
@@ -7,7 +16,7 @@
   cfg = config.soispha.programs.taskwarrior;
 
   hooksDir =
-    pkgs.runCommandNoCCLocal "mk-taskwarrior-hooks" {}
+    pkgs.runCommandLocal "mk-taskwarrior-hooks" {}
     (''
         mkdir "$out"
       ''
@@ -23,19 +32,24 @@
 
     executable = pkgs.writeShellApplication {
       name = "add-hook-${builtins.baseNameOf path}";
-      runtimeInputs = [pkgs.taskwarrior3 pkgs.coreutils] ++ deps;
+      runtimeInputs = [pkgs.taskwarrior3 pkgs.coreutils pkgs.gnugrep] ++ deps;
       inheritPath = false;
       text =
         # bash
         ''
           die() {
-            echo "$@"
+            echo "$@">&2
             exit 1
           }
 
           enable_hook_dbg() {
-              debug_hooks="$(task _get rc.debug.hooks)"
-              [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && set -x
+              # TODO: We should probably be smarter with the debug detection <2025-04-04>
+              if echo "$2" | grep --quiet 'rc.debug.hooks='; then
+                set -x
+                mkdir --parents "$HOME/.cache/task"
+                exec >>"$HOME/.cache/task/hook.log.$1"
+                exec 2>>"$HOME/.cache/task/hook.log.$1"
+              fi
           }
 
           addedCall() {
@@ -51,7 +65,7 @@
           # We don't change the task, thus immediately return the JSON
           echo "$new_task"
 
-          enable_hook_dbg
+          enable_hook_dbg "$@"
           addedCall "$new_task" "$old_task"
 
           exit 0
@@ -62,6 +76,8 @@ in {
   options.soispha.programs.taskwarrior = {
     enable = lib.mkEnableOption "taskwarrior";
 
+    enableAge = lib.mkEnableOption "taskwarrior with age keys";
+
     includeFiles = lib.mkOption {
       type = lib.types.attrsOf lib.types.path;
       description = "Extra files to include in the taskwarrior config";
@@ -94,8 +110,17 @@ in {
       inherit mkHook;
     };
 
+    age.secrets.taskwarrior_sync_server_encryption_key = lib.mkIf (cfg.enable && cfg.enableAge) {
+      file = ./secrets/sync_server_encryption_key.age;
+      mode = "700";
+      owner = "soispha";
+      group = "users";
+    };
+
+    soispha.programs.taskwarrior.includeFiles.syncServerSecret = lib.mkIf (cfg.enable && cfg.enableAge) config.age.secrets.taskwarrior_sync_server_encryption_key.path;
+
     home-manager.users.soispha = lib.mkIf cfg.enable {
-      services.taskwarrior-sync = {
+      services.taskwarrior-sync = lib.mkIf cfg.enableAge {
         enable = true;
         package = pkgs.taskwarrior3;
       };
@@ -113,6 +138,8 @@ in {
             tags = true;
           };
 
+          news.version = "3.4.1";
+
           regex = true;
           weekstart = "Monday";
 
@@ -123,6 +150,11 @@ in {
             };
           };
 
+          sync.server = lib.mkIf cfg.enableAge {
+            client_id = "a3619d43-031f-4f85-848f-5512804f9a1d";
+            url = "https://taskchampion.vhack.eu";
+          };
+
           alias = {
             mod = "modify";
           };