mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 15:14:26 +00:00
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
|
@ -179,4 +179,5 @@ The state version in this release includes the changes below. These
|
|||
changes are only active if the `home.stateVersion` option is set to
|
||||
"21.05" or later.
|
||||
|
||||
* Nothing has happened.
|
||||
* The `newsboat` module now stores generated configuration in
|
||||
`$XDG_CONFIG_HOME/newsboat`.
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
newsboat-basics = ./newsboat-basics.nix;
|
||||
newsboat-basics-2003 = ./newsboat-basics-2003.nix;
|
||||
newsboat-basics-2105 = ./newsboat-basics-2105.nix;
|
||||
}
|
||||
|
|
36
tests/modules/programs/newsboat/newsboat-basics-2105.nix
Normal file
36
tests/modules/programs/newsboat/newsboat-basics-2105.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
home.stateVersion = "21.05";
|
||||
|
||||
programs.newsboat = {
|
||||
enable = true;
|
||||
|
||||
urls = [
|
||||
{
|
||||
url = "http://example.org/feed.xml";
|
||||
tags = [ "tag1" "tag2" ];
|
||||
title = "Cool feed";
|
||||
}
|
||||
|
||||
{ url = "http://example.org/feed2.xml"; }
|
||||
];
|
||||
|
||||
queries = { "foo" = ''rssurl =~ "example.com"''; };
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; })
|
||||
];
|
||||
|
||||
# The format didn't change since 20.03, just the location.
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/newsboat/urls \
|
||||
${./newsboat-basics-urls-2003.txt}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue