From 3a9a44daac682fcf57ee312788ffc14867c412f9 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sun, 1 Oct 2023 17:08:33 +0200 Subject: feat(hm/conf/taskwarrior): Add hook scripts --- hm/soispha/conf/taskwarrior/hooks/default.nix | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 hm/soispha/conf/taskwarrior/hooks/default.nix (limited to 'hm/soispha/conf/taskwarrior/hooks/default.nix') 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"; + }; + }; +} -- cgit 1.4.1