about summary refs log tree commit diff stats
path: root/modules/by-name/ti/timewarrior/module.nix
blob: f33d02be910f0e1b165b3c9dd8314987b4b5f454 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.soispha.programs.timewarrior;

  track_timewarrior = pkgs.stdenv.mkDerivation {
    name = "track-timewarrior";
    nativeBuildInputs = [
      pkgs.makeWrapper
    ];
    buildInputs = [
      pkgs.timewarrior
      pkgs.taskwarrior3
      pkgs.python3
    ];
    dontUnpack = true;
    installPhase = ''
      install -Dm755 ${./taskwarrior_hooks/on-modify.track-timewarrior.py} $out/bin/track-timewarrior
      wrapProgram $out/bin/track-timewarrior \
      --set PATH ${lib.makeBinPath [pkgs.taskwarrior3 pkgs.timewarrior]}
    '';

    meta.mainProgram = "track-timewarrior";
  };
  track_total_active_time = pkgs.stdenv.mkDerivation {
    name = "track-total-active-time";
    nativeBuildInputs = [
      pkgs.makeWrapper
    ];
    buildInputs = [
      pkgs.taskwarrior3
      pkgs.python3
    ];
    dontUnpack = true;
    installPhase = ''
      install -Dm755 ${./taskwarrior_hooks/on-modify.track-total-active-time.py} $out/bin/track-total-active-time
      wrapProgram $out/bin/track-total-active-time \
      --set PATH ${lib.makeBinPath [pkgs.taskwarrior3]}
    '';

    meta.mainProgram = "track-total-active-time";
  };
in {
  options.soispha.programs.timewarrior = {
    enable = lib.mkEnableOption "timewarrior";
  };
  config = lib.mkIf cfg.enable {
    soispha.programs.taskwarrior = {
      hooks = {
        track-timewarrior = {
          mode = "on-modify";
          executable = track_timewarrior;
        };
        track-total-active-time = {
          mode = "on-modify";
          executable = track_total_active_time;
        };
      };
    };

    home-manager.users.soispha = {
      home.packages = [
        pkgs.timewarrior
      ];

      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
      '';
    };
  };
}