2018-09-13 19:36:57 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.taskwarrior;
|
|
|
|
|
|
|
|
formatValue = value:
|
2020-02-02 00:39:17 +01:00
|
|
|
if isBool value then
|
|
|
|
if value then "true" else "false"
|
|
|
|
else if isList value then
|
|
|
|
concatMapStringsSep "," formatValue value
|
|
|
|
else
|
|
|
|
toString value;
|
2018-09-13 19:36:57 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
formatLine = key: value: "${key}=${formatValue value}";
|
2018-09-13 19:36:57 +02:00
|
|
|
|
|
|
|
formatSet = key: values:
|
|
|
|
(concatStringsSep "\n"
|
2020-02-02 00:39:17 +01:00
|
|
|
(mapAttrsToList (subKey: subValue: formatPair "${key}.${subKey}" subValue)
|
2018-09-13 19:36:57 +02:00
|
|
|
values));
|
|
|
|
|
|
|
|
formatPair = key: value:
|
2020-02-02 00:39:17 +01:00
|
|
|
if isAttrs value then formatSet key value else formatLine key value;
|
2018-09-13 19:36:57 +02:00
|
|
|
|
2022-04-07 19:29:53 +02:00
|
|
|
homeConf = "${config.xdg.configHome}/task/home-manager-taskrc";
|
|
|
|
userConf = "${config.xdg.configHome}/task/taskrc";
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2018-09-13 19:36:57 +02:00
|
|
|
options = {
|
|
|
|
programs.taskwarrior = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "Task Warrior";
|
2018-09-13 19:36:57 +02:00
|
|
|
|
|
|
|
config = mkOption {
|
2020-11-30 03:54:55 +01:00
|
|
|
type = types.attrsOf types.anything;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2018-09-13 19:36:57 +02:00
|
|
|
{
|
|
|
|
confirmation = false;
|
|
|
|
report.minimal.filter = "status:pending";
|
|
|
|
report.active.columns = [ "id" "start" "entry.age" "priority" "project" "due" "description" ];
|
|
|
|
report.active.labels = [ "ID" "Started" "Age" "Priority" "Project" "Due" "Description" ];
|
|
|
|
taskd = {
|
|
|
|
certificate = "/path/to/cert";
|
|
|
|
key = "/path/to/key";
|
|
|
|
ca = "/path/to/ca";
|
|
|
|
server = "host.domain:53589";
|
|
|
|
credentials = "Org/First Last/cf31f287-ee9e-43a8-843e-e8bbd5de4294";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2018-09-13 19:36:57 +02:00
|
|
|
Key-value configuration written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/task/taskrc`.
|
2018-09-13 19:36:57 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataLocation = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${config.xdg.dataHome}/task";
|
|
|
|
defaultText = "$XDG_DATA_HOME/task";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2018-09-13 19:36:57 +02:00
|
|
|
Location where Task Warrior will store its data.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
2018-09-13 19:36:57 +02:00
|
|
|
Home Manager will attempt to create this directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
colorTheme = mkOption {
|
|
|
|
type = with types; nullOr (either str path);
|
|
|
|
default = null;
|
|
|
|
example = "dark-blue-256";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2018-09-13 19:36:57 +02:00
|
|
|
Either one of the default provided theme as string, or a
|
|
|
|
path to a theme configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2018-09-13 19:36:57 +02:00
|
|
|
Additional content written at the end of
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/task/taskrc`.
|
2018-09-13 19:36:57 +02:00
|
|
|
'';
|
|
|
|
};
|
2023-05-11 14:04:17 +02:00
|
|
|
|
2024-08-30 20:48:07 +02:00
|
|
|
package =
|
|
|
|
mkPackageOption pkgs "taskwarrior" { example = "pkgs.taskwarrior3"; };
|
2018-09-13 19:36:57 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-05-11 14:04:17 +02:00
|
|
|
home.packages = [ cfg.package ];
|
2018-09-13 19:36:57 +02:00
|
|
|
|
2022-04-07 19:29:53 +02:00
|
|
|
home.file."${homeConf}".text = ''
|
2018-09-13 19:36:57 +02:00
|
|
|
data.location=${cfg.dataLocation}
|
2021-11-24 03:33:03 +01:00
|
|
|
${optionalString (cfg.colorTheme != null) (if isString cfg.colorTheme then
|
|
|
|
"include ${cfg.colorTheme}.theme"
|
|
|
|
else
|
|
|
|
"include ${cfg.colorTheme}")}
|
2018-09-13 19:36:57 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
${concatStringsSep "\n" (mapAttrsToList formatPair cfg.config)}
|
2018-09-13 19:36:57 +02:00
|
|
|
|
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
2022-04-07 19:29:53 +02:00
|
|
|
|
|
|
|
home.activation.regenDotTaskRc = hm.dag.entryAfter [ "writeBoundary" ] ''
|
2024-01-23 22:59:26 +01:00
|
|
|
verboseEcho "Ensuring generated taskwarrior config included in taskrc"
|
2022-04-07 19:29:53 +02:00
|
|
|
|
|
|
|
if [[ ! -s "${userConf}" ]]; then
|
|
|
|
# Ensure file's existence
|
|
|
|
if [[ -v DRY_RUN ]]; then
|
2024-01-13 23:15:00 +01:00
|
|
|
run echo "include ${homeConf}" ">" "${userConf}"
|
2022-04-07 19:29:53 +02:00
|
|
|
else
|
|
|
|
echo "include ${homeConf}" > "${userConf}"
|
|
|
|
fi
|
2022-04-07 23:35:55 +02:00
|
|
|
elif ! grep -qF "include ${homeConf}" ${escapeShellArg userConf}; then
|
|
|
|
# Add include statement for Home Manager generated config.
|
2024-01-13 23:15:00 +01:00
|
|
|
run sed -i '1i include ${homeConf}' ${escapeShellArg userConf}
|
2022-04-07 19:29:53 +02:00
|
|
|
fi
|
|
|
|
'';
|
2018-09-13 19:36:57 +02:00
|
|
|
};
|
|
|
|
}
|