diff --git a/modules/universal/env/feeds.nix b/modules/universal/env/feeds.nix index 2717e57b9..b24fb0c36 100644 --- a/modules/universal/env/feeds.nix +++ b/modules/universal/env/feeds.nix @@ -1,4 +1,6 @@ -{ +{ lib }: + +rec { # TODO: fold this into RSS, with an `audio` category podcastUrls = [ "https://lexfridman.com/feed/podcast/" @@ -118,4 +120,29 @@ # CODE "https://github.com/Kaiteki-Fedi/Kaiteki/commits/master.atom" = tech // infrequent; }; + + # return only the URLs which match this category + filterCat = cat: builtins.filter (url: rss."${url}".cat == cat) (builtins.attrNames rss); + + # represents a single RSS feed. + opmlTerminal = url: ''''; + # a list of RSS feeds. + opmlTerminals = urls: lib.strings.concatStringsSep "\n" (builtins.map opmlTerminal urls); + # one node which packages some flat grouping of terminals. + opmlGroup = title: urls: '' + + ${opmlTerminals urls} + + ''; + # top-level OPML file which could be consumed by something else. + opmlToplevel = bodies: + let + body = lib.strings.concatStringsSep "\n" bodies; + in '' + + + ${body} + + + ''; } diff --git a/modules/universal/env/home-manager.nix b/modules/universal/env/home-manager.nix index dcb21a0de..20b94d081 100644 --- a/modules/universal/env/home-manager.nix +++ b/modules/universal/env/home-manager.nix @@ -17,7 +17,7 @@ let # extract `persist-files` from `extraPackages` persistfileslist = pkgspec: builtins.concatLists (builtins.map (e: if e ? "persist-files" then e.persist-files else []) pkgspec); # TODO: dirlist and persistfileslist should be folded - feeds = import ./feeds.nix; + feeds = import ./feeds.nix { inherit lib; }; in { options = { @@ -216,54 +216,21 @@ in qt-privacy-ask=0 ''; - xdg.configFile."gpodderFeeds.opml".text = - let - entries = builtins.toString (builtins.map - (url: "\n " + '''') - feeds.podcastUrls - ); - in '' - - - ${entries} - - - ''; + xdg.configFile."gpodderFeeds.opml".text = with feeds; + opmlToplevel [(opmlTerminals podcastUrls)]; # news-flash RSS viewer - xdg.configFile."newsflashFeeds.opml".text = + xdg.configFile."newsflashFeeds.opml".text = with feeds; let - entries = feeds.rss; - urlsForCat = cat: builtins.filter (rss: entries."${rss}".cat == cat) (builtins.attrNames entries); - outlineEntriesFor = cat: builtins.map (rss: '' - - '') (urlsForCat cat); - outlineFor = cat: let - outlines = outlineEntriesFor cat; - in '' - - ${builtins.toString outlines} - - ''; + opmlForCat = cat: opmlGroup cat (filterCat cat); outlines = [ - (outlineFor "uncat") - (outlineFor "rat") - (outlineFor "tech") - (outlineFor "pol") - (outlineFor "visual") + (opmlForCat "uncat") + (opmlForCat "rat") + (opmlForCat "tech") + (opmlForCat "pol") + (opmlForCat "visual") ]; - in '' - - - - NewsFlash OPML export - - - ${builtins.toString outlines} - - - ''; - + in opmlToplevel outlines; # gnome feeds RSS viewer xdg.configFile."org.gabmus.gfeeds.json".text = builtins.toJSON {