newsboat: support feed titles

Fixes #861
This commit is contained in:
Robert Helgesson 2019-10-07 23:51:12 +02:00
parent 79c16b9a90
commit 90bf989002
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
5 changed files with 79 additions and 12 deletions

View file

@ -14,10 +14,32 @@ in
enable = mkEnableOption "the Newsboat feed reader"; enable = mkEnableOption "the Newsboat feed reader";
urls = mkOption { urls = mkOption {
type = types.listOf types.attrs; type = types.listOf (types.submodule {
options = {
url = mkOption {
type = types.str;
example = "http://example.com";
description = "Feed URL.";
};
tags = mkOption {
type = types.listOf types.str;
default = [];
example = ["foo" "bar"];
description = "Feed tags.";
};
title = mkOption {
type = types.nullOr types.str;
default = null;
example = "ORF News";
description = "Feed title.";
};
};
});
default = []; default = [];
example = [{url = "http://example.com"; tags = ["foo" "bar"];}]; example = [{url = "http://example.com"; tags = ["foo" "bar"];}];
description = "List of urls and tokens."; description = "List of news feeds.";
}; };
maxItems = mkOption { maxItems = mkOption {
@ -71,19 +93,18 @@ in
home.packages = [ pkgs.newsboat ]; home.packages = [ pkgs.newsboat ];
home.file.".newsboat/urls".text = home.file.".newsboat/urls".text =
let let
urls = builtins.concatStringsSep "\n" ( mkUrlEntry = u: concatStringsSep " " (
map (u: builtins.concatStringsSep " " ([u.url] ++ (map wrapQuote u.tags))) [u.url]
cfg.urls); ++ map wrapQuote u.tags
queries = builtins.concatStringsSep "\n" ( ++ optional (u.title != null) (wrapQuote "~${u.title}")
mapAttrsToList (n: v: "\"query:${n}:${escape ["\""] v}\"") cfg.queries); );
urls = map mkUrlEntry cfg.urls;
mkQueryEntry = n: v: "\"query:${n}:${escape ["\""] v}\"";
queries = mapAttrsToList mkQueryEntry cfg.queries;
in in
concatStringsSep "\n" (urls ++ queries) + "\n";
''
${urls}
${queries}
'';
home.file.".newsboat/config".text = '' home.file.".newsboat/config".text = ''
max-items ${toString cfg.maxItems} max-items ${toString cfg.maxItems}
browser ${cfg.browser} browser ${cfg.browser}

View file

@ -46,6 +46,7 @@ import nmt {
// import ./modules/programs/alacritty // import ./modules/programs/alacritty
// import ./modules/programs/bash // import ./modules/programs/bash
// import ./modules/programs/gpg // import ./modules/programs/gpg
// import ./modules/programs/newsboat
// import ./modules/programs/ssh // import ./modules/programs/ssh
// import ./modules/programs/tmux // import ./modules/programs/tmux
// import ./modules/programs/zsh; // import ./modules/programs/zsh;

View file

@ -0,0 +1,3 @@
{
newsboat-basics = ./newsboat-basics.nix;
}

View file

@ -0,0 +1,3 @@
http://example.org/feed.xml "tag1" "tag2" "~Cool feed"
http://example.org/feed2.xml
"query:foo:rssurl =~ \"example.com\""

View file

@ -0,0 +1,39 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
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" "";
})
];
nmt.script = ''
assertFileContent \
home-files/.newsboat/urls \
${./newsboat-basics-urls.txt}
'';
};
}