about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/hooks/default.nix
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-10-01 17:08:33 +0200
committerSoispha <soispha@vhack.eu>2023-10-01 18:23:53 +0200
commit3a9a44daac682fcf57ee312788ffc14867c412f9 (patch)
treea7da1d6f0a6b9623d7b37c3877cf2a41f902cb6e /hm/soispha/conf/taskwarrior/hooks/default.nix
parentfeat(hm/pkgs/scrs/neorg): Add support for opening current task context (diff)
downloadnixos-config-3a9a44daac682fcf57ee312788ffc14867c412f9.zip
feat(hm/conf/taskwarrior): Add hook scripts
Diffstat (limited to 'hm/soispha/conf/taskwarrior/hooks/default.nix')
-rw-r--r--hm/soispha/conf/taskwarrior/hooks/default.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/hm/soispha/conf/taskwarrior/hooks/default.nix b/hm/soispha/conf/taskwarrior/hooks/default.nix
new file mode 100644
index 00000000..9bd66c38
--- /dev/null
+++ b/hm/soispha/conf/taskwarrior/hooks/default.nix
@@ -0,0 +1,46 @@
+{
+  sysLib,
+  pkgs,
+  ...
+}: let
+  enforce_policies = sysLib.writeShellScriptWithLibrary {
+    name = "enforce_policies.taskwarrior-hook";
+    src = ./scripts/on-add_enforce-policies.sh;
+    dependencies = with pkgs; [dash jq taskwarrior gnused gnugrep];
+    replacementStrings = let
+      projects = builtins.map (project: project.name) (import ../projects {});
+      projects_newline = builtins.concatStringsSep "\n" projects;
+      projects_comma = builtins.concatStringsSep ", " projects;
+    in {
+      PROJECTS_NEWLINE = projects_newline;
+      PROJECTS_COMMA = projects_comma;
+    };
+  };
+  track_timewarrior = pkgs.stdenv.mkDerivation {
+    name = "track_timewarrior.taskwarrior-hook";
+    propagatedBuildInputs = [
+      pkgs.timewarrior
+    ];
+    dontUnpack = true;
+    installPhase = "install -Dm755 ${./scripts/on-modify_track-timewarrior.py} $out/bin/bin";
+  };
+  track_total_active_time = pkgs.stdenv.mkDerivation {
+    name = "track_total_active_time.taskwarrior-hook";
+    propagatedBuildInputs = [
+      (pkgs.python3.withPackages (pythonPackages:
+        with pythonPackages; [
+          taskw
+        ]))
+    ];
+    dontUnpack = true;
+    installPhase = "install -Dm755 ${./scripts/on-modify_track-total-active-time.py} $out/bin/bin";
+  };
+in {
+  xdg = {
+    dataFile = {
+      "task/hooks/on-add_enforce-policies".source = "${enforce_policies}/bin/enforce_policies.taskwarrior-hook";
+      "task/hooks/on-modify_track-timewarrior".source = "${track_timewarrior}/bin/bin";
+      "task/hooks/on-modify_track-total-active-time".source = "${track_total_active_time}/bin/bin";
+    };
+  };
+}