mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
taskwarrior: make .taskrc writable (#2761)
This is achieved by generating the Home Manager configuration file as `~/.config/task/home-manager-taskrc`, and including that file into ~/.config/task/taskrc. Fixes #2360 Co-authored-by: mainrs <5113257+mainrs@users.noreply.github.com> Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
This commit is contained in:
parent
3604a20b67
commit
e361373b5f
2 changed files with 26 additions and 4 deletions
|
@ -24,6 +24,8 @@ let
|
|||
formatPair = key: value:
|
||||
if isAttrs value then formatSet key value else formatLine key value;
|
||||
|
||||
homeConf = "${config.xdg.configHome}/task/home-manager-taskrc";
|
||||
userConf = "${config.xdg.configHome}/task/taskrc";
|
||||
in {
|
||||
options = {
|
||||
programs.taskwarrior = {
|
||||
|
@ -88,7 +90,7 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
home.packages = [ pkgs.taskwarrior ];
|
||||
|
||||
xdg.configFile."task/taskrc".text = ''
|
||||
home.file."${homeConf}".text = ''
|
||||
data.location=${cfg.dataLocation}
|
||||
${optionalString (cfg.colorTheme != null) (if isString cfg.colorTheme then
|
||||
"include ${cfg.colorTheme}.theme"
|
||||
|
@ -99,5 +101,25 @@ in {
|
|||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
home.activation.regenDotTaskRc = hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
$VERBOSE_ECHO "Ensuring generated taskwarrior config included in taskrc"
|
||||
|
||||
if [[ ! -s "${userConf}" ]]; then
|
||||
# Ensure file's existence
|
||||
if [[ -v DRY_RUN ]]; then
|
||||
$DRY_RUN_CMD echo "include ${homeConf}" ">" "${userConf}"
|
||||
else
|
||||
echo "include ${homeConf}" > "${userConf}"
|
||||
fi
|
||||
elif ! ${pkgs.gnugrep}/bin/grep -qF "include ${homeConf}" ${
|
||||
escapeShellArg userConf
|
||||
}; then
|
||||
# Add include statement for home-manager generated config
|
||||
$DRY_RUN_CMD ${pkgs.gnused}/bin/sed -i '1i include ${homeConf}' ${
|
||||
escapeShellArg userConf
|
||||
}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ with lib;
|
|||
test.stubs.taskwarrior = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/task/taskrc
|
||||
assertFileContent home-files/.config/task/taskrc ${
|
||||
pkgs.writeText "taskwarrior.expected" ''
|
||||
assertFileExists home-files/.config/task/home-manager-taskrc
|
||||
assertFileContent home-files/.config/task/home-manager-taskrc ${
|
||||
pkgs.writeText "taskwarrior.home-conf.expected" ''
|
||||
data.location=/some/data/location
|
||||
include dark-violets-256.theme
|
||||
|
||||
|
|
Loading…
Reference in a new issue