about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/hooks/default.nix
blob: 9bd66c383b3766bb3cae31b43ce9af46954b6b83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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";
    };
  };
}