taskwarrior: change config file location and use relative theme paths (#2455)

After taskwarrior 2.6.0, its default config file now locates at
`$XDG_CONFIG_HOME/task/taskrc`, and builtin themes can be included
via relative paths.
This commit is contained in:
oxalica 2021-11-24 10:33:03 +08:00 committed by GitHub
parent c4c761ba55
commit df931a59a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 14 deletions

View file

@ -37,6 +37,10 @@ https://github.com/nix-community/home-manager/issues/1906[issue #1906].
+
You can replicate your old configuration by moving those options to <<opt-programs.rofi.theme>>. Keep in mind that the syntax is different so you may need to do some changes.
* Taskwarrior version 2.6.0 respects XDG Specification for the config file now.
Option <<opt-programs.taskwarrior.config>> and friends now generate the config file at
`$XDG_CONFIG_HOME/task/taskrc` instead of `~/.taskrc`.
[[sec-release-21.11-state-version-changes]]
=== State Version Changes

View file

@ -2241,6 +2241,15 @@ in
A new module is available: 'wayland.windowManager.sway.swaynag'.
'';
}
{
time = "2021-11-23T20:26:37+00:00";
message = ''
Taskwarrior version 2.6.0 respects XDG Specification for the config file now.
Option 'opt-programs.taskwarrior.config' and friends now generate the config file at
'$XDG_CONFIG_HOME/task/taskrc' instead of '~/.taskrc'.
'';
}
];
};
}

View file

@ -6,16 +6,6 @@ let
cfg = config.programs.taskwarrior;
themePath = theme: "${pkgs.taskwarrior}/share/doc/task/rc/${theme}.theme";
includeTheme = location:
if location == null then
""
else if isString location then
"include ${themePath location}"
else
"include ${location}";
formatValue = value:
if isBool value then
if value then "true" else "false"
@ -59,7 +49,7 @@ in {
'';
description = ''
Key-value configuration written to
<filename>~/.taskrc</filename>.
<filename>$XDG_CONFIG_HOME/task/taskrc</filename>.
'';
};
@ -89,7 +79,7 @@ in {
default = "";
description = ''
Additional content written at the end of
<filename>~/.taskrc</filename>.
<filename>$XDG_CONFIG_HOME/task/taskrc</filename>.
'';
};
};
@ -98,9 +88,12 @@ in {
config = mkIf cfg.enable {
home.packages = [ pkgs.taskwarrior ];
home.file.".taskrc".text = ''
xdg.configFile."task/taskrc".text = ''
data.location=${cfg.dataLocation}
${includeTheme cfg.colorTheme}
${optionalString (cfg.colorTheme != null) (if isString cfg.colorTheme then
"include ${cfg.colorTheme}.theme"
else
"include ${cfg.colorTheme}")}
${concatStringsSep "\n" (mapAttrsToList formatPair cfg.config)}

View file

@ -87,6 +87,7 @@ import nmt {
./modules/programs/sm64ex
./modules/programs/ssh
./modules/programs/starship
./modules/programs/taskwarrior
./modules/programs/texlive
./modules/programs/tmux
./modules/programs/topgrade

View file

@ -0,0 +1 @@
{ taskwarrior = ./taskwarrior.nix; }

View file

@ -0,0 +1,40 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.taskwarrior = {
enable = true;
colorTheme = "dark-violets-256";
dataLocation = "/some/data/location";
config = {
urgency.user.tag.next.coefficient = 42.42;
urgency.blocked.coefficient = -42;
};
extraConfig = ''
include /my/stuff
urgency.user.tag.test.coefficient=-42.42
'';
};
test.stubs.taskwarrior = { };
nmt.script = ''
assertFileExists home-files/.config/task/taskrc
assertFileContent home-files/.config/task/taskrc ${
pkgs.writeText "taskwarrior.expected" ''
data.location=/some/data/location
include dark-violets-256.theme
urgency.blocked.coefficient=-42
urgency.user.tag.next.coefficient=42.420000
include /my/stuff
urgency.user.tag.test.coefficient=-42.42
''
}
'';
};
}