about summary refs log tree commit diff stats
path: root/modules/by-name/ti/timewarrior/module.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-04 11:55:51 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-04 11:55:51 +0200
commitae373d7927bcb0148f6714f4438008433882ffbc (patch)
tree4c067cdcf0afb928782d334e348027d2832f6d17 /modules/by-name/ti/timewarrior/module.nix
parentfeat(modules/tskm): Init module (diff)
downloadnixos-config-ae373d7927bcb0148f6714f4438008433882ffbc.zip
refactor(modules/timewarrior): Migrate to by-name
Diffstat (limited to 'modules/by-name/ti/timewarrior/module.nix')
-rw-r--r--modules/by-name/ti/timewarrior/module.nix96
1 files changed, 96 insertions, 0 deletions
diff --git a/modules/by-name/ti/timewarrior/module.nix b/modules/by-name/ti/timewarrior/module.nix
new file mode 100644
index 00000000..e4087e69
--- /dev/null
+++ b/modules/by-name/ti/timewarrior/module.nix
@@ -0,0 +1,96 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}: let
+  cfg = config.soispha.programs.timewarrior;
+
+  track_timewarrior = pkgs.stdenv.mkDerivation {
+    name = "track_timewarrior.taskwarrior-hook";
+    nativeBuildInputs = [
+      pkgs.makeWrapper
+    ];
+    buildInputs = [
+      pkgs.timewarrior
+      pkgs.taskwarrior
+      # TODO: Use a `taskw` package, that actually supports newer python variants <2024-07-13>
+      (pkgs.python311.withPackages (pythonPackages:
+        with pythonPackages; [
+          taskw
+        ]))
+    ];
+    dontUnpack = true;
+    installPhase = ''
+      install -Dm755 ${./taskwarirror_hooks/on-modify_track-timewarrior.py} $out/bin/bin
+      wrapProgram $out/bin/bin \
+      --prefix PATH : ${lib.makeBinPath [pkgs.taskwarrior pkgs.timewarrior]}
+    '';
+
+    meta.mainProgram = "bin";
+  };
+  track_total_active_time = pkgs.stdenv.mkDerivation {
+    name = "track_total_active_time.taskwarrior-hook";
+    nativeBuildInputs = [
+      pkgs.makeWrapper
+    ];
+    buildInputs = [
+      pkgs.taskwarrior
+      # TODO: Use a `taskw` package, that actually supports newer python variants <2024-07-13>
+      (pkgs.python311.withPackages (pythonPackages:
+        with pythonPackages; [
+          taskw
+        ]))
+    ];
+    dontUnpack = true;
+    installPhase = ''
+      install -Dm755 ${./taskwarirror_hooks/on-modify_track-total-active-time.py} $out/bin/bin
+      wrapProgram $out/bin/bin \
+      --prefix PATH : ${lib.makeBinPath [pkgs.taskwarrior]}
+    '';
+
+    meta.mainProgram = "bin";
+  };
+in {
+  options.soispha.programs.timewarrior = {
+    enable = lib.mkEnableOption "timewarrior";
+  };
+  config = lib.mkIf cfg.enable {
+    home-manager.users.soispha = {
+      home.packages = [
+        pkgs.timewarrior
+      ];
+
+      soispha.programs.taskwarrior = {
+        hooks = {
+          track-timewarrior = {
+            mode = "on-modify";
+            executable = track_timewarrior;
+          };
+          track-total-active-time = {
+            mode = "on-modify";
+            executable = track_total_active_time;
+          };
+        };
+      };
+
+      xdg.configFile."timewarrior/timewarrior.cfg".text = ''
+        # source: https://github.com/arcticicestudio/igloo
+        #+----+
+        #+ UI +
+        #+----+
+        import ${./nord.theme}
+        color = true
+
+        #+---------+
+        #+ Reports +
+        #+---------+
+        define reports:
+          day:
+            lines = 10
+            month = true
+            week = true
+      '';
+    };
+  };
+}