nixos/users/malte/taskwarrior.nix
2022-02-15 14:58:39 +01:00

74 lines
2.3 KiB
Nix

{ pkgs, lib, config, ... }:
let
# Data storage location for taskwarrior
dataLocation = "/home/malte/Tasks";
# A usable (with dateutil) python interpreter for timewarrior's totals.py extension
pythonWithLibs = pkgs.python3.withPackages (ps: [ ps.dateutil ]);
# This is a patched version of the upstream `totals.py` script
# so sum up timewarrior stats
# This just patches the first line to use a python interpreter that has
# `dateutil` available!
timewarriorExtensions = pkgs.stdenvNoCC.mkDerivation {
name = "timewarrior-totals";
version = "v1.4.3";
src = pkgs.fetchFromGitHub {
owner = "GothenburgBitFactory";
repo = "timewarrior";
rev = "v1.4.3";
sha256 = "+HsUiU287bWZ5Ytl+N5i+STuG9YlqlaKWxd69y0PRds=";
};
buildInputs = [ pkgs.coreutils ];
propagatedBuildInputs = [ pythonWithLibs ];
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
patchPhase = ''
sed -i 's|^#!/usr/bin/env python3$|#!${pythonWithLibs}/bin/python3|' \
ext/totals.py \
ext/on-modify.timewarrior
'';
installPhase = ''
mkdir -p $out
cp ext/totals.py ext/on-modify.timewarrior $out/
'';
};
in {
# Install timewarrior aswell!
# Timewarrior hook needs Python3.. or a patch.. to lazy for the latter
home.packages = with pkgs; [ timewarrior python3 ];
programs.taskwarrior = {
inherit dataLocation;
enable = true;
colorTheme = "dark-256";
config = {
include = "${pkgs.taskwarrior}/share/doc/task/rc/holidays.de-DE.rc";
urgency.user.tag = {
irgendwann.coefficient = "-100.0";
extern.coefficient = "-50.0";
};
dateformat = "D.M.Y H:N";
uda.reviewed = {
type = "date";
label = "Reviewed";
};
report._reviewed = {
description = "Tasksh review report. Adjust the filter to your needs.";
columns = "uuid";
sort = "reviewed+,modified+";
filter =
"( reviewed.none: or reviewed.before:now-6days ) and ( +PENDING )";
};
};
};
home.file.".timewarrior/extensions/totals.py".source =
"${timewarriorExtensions}/totals.py";
home.file."${dataLocation}/hooks/on-modify-timewarrior" = {
source = "${timewarriorExtensions}/on-modify.timewarrior";
executable = true;
};
}