nixos-config/modules/programs/taskwarrior.nix
2020-03-10 11:49:36 +08:00

68 lines
1.7 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.custom.taskwarrior;
unstable = import <nixpkgs-unstable> { };
taskNextWeek = pkgs.writeShellScriptBin "taskweek" # sh
''
${pkgs.taskwarrior}/bin/task \
export \
status:pending and \( due.before:6days \) \
| ${pkgs.jq}/bin/jq '[.[] | { Day: .due, ID: .id, Description: .description } ] | sort_by(.Day)' \
| ${pkgs.miller}/bin/mlr --ijson --opprint put "\$Day = strftime(strptime(\$Day,\"%Y%m%dT%H%M%SZ\")$(date +%z)00,\"%A\")"
'';
tsak = pkgs.writeShellScriptBin "tsak" # sh
''
${pkgs.taskwarrior}/bin/task "$@"
'';
in {
options.programs.custom.taskwarrior.enable =
mkEnableOption "Enable Taskwarrior services";
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
taskwarrior
timewarrior
tasksh
taskNextWeek
tsak
(unstable.vit.overrideAttrs (old: rec {
name = "vit-${version}";
version = "master";
src = pkgs.fetchgit {
url = "https://github.com/scottkosty/vit.git";
rev = "41d046e86c1ff73a95d78b66149e3fb30a6aac85";
sha256 = "0xkh5hiryh7nwi17wrp1pxscbw0a2fdw349mhgvx59hafpkf13nv";
};
}))
python # needed for hooks
taskwarrior-hooks
# bugwarrior
(let
mypython = let
packageOverrides = self: super: {
bugwarrior = super.bugwarrior.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs
++ [ super.setuptools ];
});
};
in pkgs.python3.override { inherit packageOverrides; };
in mypython.pkgs.bugwarrior)
];
};
}