1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 10:49:48 +01:00
home-manager/modules/programs/taskwarrior.nix

113 lines
3 KiB
Nix
Raw Normal View History

2018-09-13 19:36:57 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.taskwarrior;
themePath = theme: "${pkgs.taskwarrior}/share/doc/task/rc/${theme}.theme";
includeTheme = location:
2020-02-02 00:39:17 +01:00
if location == null then
""
else if isString location then
"include ${themePath location}"
else
"include ${location}";
2018-09-13 19:36:57 +02:00
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
2020-02-02 00:39:17 +01:00
in {
2018-09-13 19:36:57 +02:00
options = {
programs.taskwarrior = {
enable = mkEnableOption "Task Warrior";
config = mkOption {
type = types.attrsOf types.anything;
2020-02-02 00:39:17 +01:00
default = { };
2018-09-13 19:36:57 +02:00
example = literalExample ''
{
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";
};
}
'';
description = ''
Key-value configuration written to
<filename>~/.taskrc</filename>.
'';
};
dataLocation = mkOption {
type = types.str;
default = "${config.xdg.dataHome}/task";
defaultText = "$XDG_DATA_HOME/task";
description = ''
Location where Task Warrior will store its data.
</para><para>
Home Manager will attempt to create this directory.
'';
};
colorTheme = mkOption {
type = with types; nullOr (either str path);
default = null;
example = "dark-blue-256";
description = ''
Either one of the default provided theme as string, or a
path to a theme configuration file.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Additional content written at the end of
<filename>~/.taskrc</filename>.
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.taskwarrior ];
home.file."${cfg.dataLocation}/.keep".text = "";
home.file.".taskrc".text = ''
data.location=${cfg.dataLocation}
${includeTheme cfg.colorTheme}
2020-02-02 00:39:17 +01:00
${concatStringsSep "\n" (mapAttrsToList formatPair cfg.config)}
2018-09-13 19:36:57 +02:00
${cfg.extraConfig}
'';
};
}