newsboat: use $XDG_CONFIG_HOME/newsboat
As of Newsboat 2.19, configuration using XDG_CONFIG_HOME/newsboat is supported: https://newsboat.org/releases/2.19/docs/newsboat.html#_xdg_base_directory_support This is a continuation of #1331 and includes gating logic so that the change doesn't happen until state version 21.05. Supersedes and Closes #1331
This commit is contained in:
parent
18930aaf75
commit
f7159a0f76
4 changed files with 75 additions and 25 deletions
|
|
@ -6,6 +6,32 @@ let
|
|||
cfg = config.programs.newsboat;
|
||||
wrapQuote = x: ''"${x}"'';
|
||||
|
||||
urlsFileContents = let
|
||||
mkUrlEntry = u:
|
||||
concatStringsSep " " ([ u.url ] ++ map wrapQuote u.tags
|
||||
++ optional (u.title != null) (wrapQuote "~${u.title}"));
|
||||
urls = map mkUrlEntry cfg.urls;
|
||||
|
||||
mkQueryEntry = n: v: ''"query:${n}:${escape [ ''"'' ] v}"'';
|
||||
queries = mapAttrsToList mkQueryEntry cfg.queries;
|
||||
in concatStringsSep "\n"
|
||||
(if versionAtLeast config.home.stateVersion "20.03" then
|
||||
queries ++ urls
|
||||
else
|
||||
urls ++ queries) + "\n";
|
||||
|
||||
configFileContents = ''
|
||||
max-items ${toString cfg.maxItems}
|
||||
browser ${cfg.browser}
|
||||
reload-threads ${toString cfg.reloadThreads}
|
||||
auto-reload ${if cfg.autoReload then "yes" else "no"}
|
||||
${optionalString (cfg.reloadTime != null)
|
||||
(toString "reload-time ${toString cfg.reloadTime}")}
|
||||
prepopulate-query-feeds yes
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
in {
|
||||
options = {
|
||||
programs.newsboat = {
|
||||
|
|
@ -94,30 +120,16 @@ in {
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ pkgs.newsboat ];
|
||||
home.file.".newsboat/urls".text = let
|
||||
mkUrlEntry = u:
|
||||
concatStringsSep " " ([ u.url ] ++ map wrapQuote u.tags
|
||||
++ optional (u.title != null) (wrapQuote "~${u.title}"));
|
||||
urls = map mkUrlEntry cfg.urls;
|
||||
|
||||
mkQueryEntry = n: v: ''"query:${n}:${escape [ ''"'' ] v}"'';
|
||||
queries = mapAttrsToList mkQueryEntry cfg.queries;
|
||||
in concatStringsSep "\n"
|
||||
(if versionAtLeast config.home.stateVersion "20.03" then
|
||||
queries ++ urls
|
||||
else
|
||||
urls ++ queries) + "\n";
|
||||
|
||||
home.file.".newsboat/config".text = ''
|
||||
max-items ${toString cfg.maxItems}
|
||||
browser ${cfg.browser}
|
||||
reload-threads ${toString cfg.reloadThreads}
|
||||
auto-reload ${if cfg.autoReload then "yes" else "no"}
|
||||
${optionalString (cfg.reloadTime != null)
|
||||
(toString "reload-time ${toString cfg.reloadTime}")}
|
||||
prepopulate-query-feeds yes
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
# Use ~/.newsboat on stateVersion < 21.05 and use ~/.config/newsboat for
|
||||
# stateVersion >= 21.05.
|
||||
home.file = mkIf (versionOlder config.home.stateVersion "21.05") {
|
||||
".newsboat/urls".text = urlsFileContents;
|
||||
".newsboat/config".text = configFileContents;
|
||||
};
|
||||
xdg.configFile = mkIf (versionAtLeast config.home.stateVersion "21.05") {
|
||||
"newsboat/urls".text = urlsFileContents;
|
||||
"newsboat/config".text = configFileContents;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue