1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

newsboat: allow imperative "urls" management

This commit allows imperative management of "urls" file. It can be
useful if "urls" file is treated as a secret.

With this change, it's possible to provision "urls" via Syncthing,
agenix, sops-nix or other means, while still managing Newsboat
declaratively.
This commit is contained in:
KFearsoff 2022-05-06 17:20:16 +05:00 committed by Robert Helgesson
parent 948d1f8a5c
commit c0f9cbcf93
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -68,7 +68,10 @@ in {
url = "http://example.com"; url = "http://example.com";
tags = [ "foo" "bar" ]; tags = [ "foo" "bar" ];
}]; }];
description = "List of news feeds."; description = ''
List of news feeds. Leave it empty if you want to manage feeds
imperatively, for example, using Syncthing.
'';
}; };
maxItems = mkOption { maxItems = mkOption {
@ -121,16 +124,24 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [{
assertion = cfg.queries != { } -> cfg.urls != [ ];
message = ''
Cannot specify queries if urls is empty. Unset queries if you
want to manage urls imperatively.
'';
}];
home.packages = [ pkgs.newsboat ]; home.packages = [ pkgs.newsboat ];
# Use ~/.newsboat on stateVersion < 21.05 and use ~/.config/newsboat for # Use ~/.newsboat on stateVersion < 21.05 and use ~/.config/newsboat for
# stateVersion >= 21.05. # stateVersion >= 21.05.
home.file = mkIf (versionOlder config.home.stateVersion "21.05") { home.file = mkIf (versionOlder config.home.stateVersion "21.05") {
".newsboat/urls".text = urlsFileContents; ".newsboat/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; };
".newsboat/config".text = configFileContents; ".newsboat/config".text = configFileContents;
}; };
xdg.configFile = mkIf (versionAtLeast config.home.stateVersion "21.05") { xdg.configFile = mkIf (versionAtLeast config.home.stateVersion "21.05") {
"newsboat/urls".text = urlsFileContents; "newsboat/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; };
"newsboat/config".text = configFileContents; "newsboat/config".text = configFileContents;
}; };
}; };