From c0f9cbcf93ca22e4f0ca66843be61a4bdf6f0a44 Mon Sep 17 00:00:00 2001 From: KFearsoff Date: Fri, 6 May 2022 17:20:16 +0500 Subject: [PATCH] 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. --- modules/programs/newsboat.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/programs/newsboat.nix b/modules/programs/newsboat.nix index ba074a421..d2782bf2d 100644 --- a/modules/programs/newsboat.nix +++ b/modules/programs/newsboat.nix @@ -68,7 +68,10 @@ in { url = "http://example.com"; 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 { @@ -121,16 +124,24 @@ in { }; 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 ]; # 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/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; }; ".newsboat/config".text = configFileContents; }; xdg.configFile = mkIf (versionAtLeast config.home.stateVersion "21.05") { - "newsboat/urls".text = urlsFileContents; + "newsboat/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; }; "newsboat/config".text = configFileContents; }; };