mirror of
https://github.com/nix-community/home-manager
synced 2024-12-23 18:29:47 +01:00
parent
79c16b9a90
commit
90bf989002
5 changed files with 79 additions and 12 deletions
|
@ -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}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
3
tests/modules/programs/newsboat/default.nix
Normal file
3
tests/modules/programs/newsboat/default.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
newsboat-basics = ./newsboat-basics.nix;
|
||||||
|
}
|
3
tests/modules/programs/newsboat/newsboat-basics-urls.txt
Normal file
3
tests/modules/programs/newsboat/newsboat-basics-urls.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
http://example.org/feed.xml "tag1" "tag2" "~Cool feed"
|
||||||
|
http://example.org/feed2.xml
|
||||||
|
"query:foo:rssurl =~ \"example.com\""
|
39
tests/modules/programs/newsboat/newsboat-basics.nix
Normal file
39
tests/modules/programs/newsboat/newsboat-basics.nix
Normal 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}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue