aboutsummaryrefslogtreecommitdiff
path: root/modules/rss
diff options
context:
space:
mode:
Diffstat (limited to 'modules/rss')
-rw-r--r--modules/rss/default.nix31
-rw-r--r--modules/rss/feeds.nix89
-rw-r--r--modules/rss/utils.nix39
3 files changed, 159 insertions, 0 deletions
diff --git a/modules/rss/default.nix b/modules/rss/default.nix
new file mode 100644
index 0000000..9473c30
--- /dev/null
+++ b/modules/rss/default.nix
@@ -0,0 +1,31 @@
+{ pkgs, settings, phenax-yayarr, ... }@attrs:
+let
+ ports = settings.network.ports;
+ yarr = settings.yarr;
+ utils = import ./utils.nix attrs;
+
+ yarrSetupScript = utils.createYarrSetupScript {
+ inherit (yarr) username api_key;
+ api_url = "http://localhost:${toString ports.yarr}";
+ feeds = import ./feeds.nix;
+ settings = {
+ theme_font = "monospace";
+ theme_name = "night";
+ theme_size = 1.1;
+ refresh_rate = 30;
+ };
+ };
+in
+{
+ services.yarr = {
+ enable = true;
+ port = ports.yarr;
+ address = "0.0.0.0";
+ package = phenax-yayarr;
+ authFilePath = pkgs.writeText "yarr-auth" ''${yarr.username}:${yarr.password}'';
+ };
+
+ networking.firewall.allowedTCPPorts = [ ports.yarr ];
+
+ environment.systemPackages = [ yarrSetupScript ];
+}
diff --git a/modules/rss/feeds.nix b/modules/rss/feeds.nix
new file mode 100644
index 0000000..f3e0978
--- /dev/null
+++ b/modules/rss/feeds.nix
@@ -0,0 +1,89 @@
+let
+ youtube = id: title: {
+ title = "${title}";
+ url = "https://www.youtube.com/feeds/videos.xml?channel_id=${id}";
+ };
+ reddit = subreddit: {
+ title = "r/${subreddit}";
+ url = "https://www.reddit.com/r/${subreddit}/top/.rss?t=month";
+ };
+in
+{
+ title = "Feed reader";
+
+ groups = {
+ "Blogs" = [
+ { url = "https://rubyonrails.org/feed.xml"; title = "Rails blog"; }
+ { url = "https://lexi-lambda.github.io/feeds/all.rss.xml"; title = "Lexi Lambda"; }
+ { url = "https://overreacted.io/rss.xml"; title = "Dan Abramov"; }
+ { url = "https://tkdodo.eu/blog/rss.xml"; title = "Tkdodo"; }
+ { url = "https://kentcdodds.com/blog/rss.xml"; title = "Kent C Dodds"; }
+ { url = "https://world.hey.com/dhh/feed.atom"; title = "DHH horseshit"; }
+ { url = "https://developer.chrome.com/blog/feed.xml"; title = "Chrome"; }
+ { url = "https://programmingisterrible.com/rss"; title = "Programming is terrible"; }
+ { url = "https://reacttraining.com/rss.xml"; title = "React Training"; }
+ { url = "https://www.developerway.com/rss.xml"; title = "Developer way"; }
+ ];
+
+ "Reddit" = [
+ (reddit "dumbphones")
+ (reddit "selfhosted")
+ (reddit "homeserver")
+ (reddit "crafting")
+ (reddit "coolguides")
+ (reddit "whittling")
+ (reddit "psychologymemes")
+ (reddit "petthedamndog")
+ (reddit "animalsbeingderps")
+ (reddit "lifeprotips")
+ (reddit "linuxmemes")
+ ];
+
+ "Dev news" = [
+ { url = "https://cprss.s3.amazonaws.com/javascriptweekly.com.xml"; title = "JS weekly"; }
+ { url = "https://cprss.s3.amazonaws.com/react.statuscode.com.xml"; title = "React status"; }
+ { url = "https://www.totaltypescript.com/rss.xml"; title = "Total typescript"; }
+ { url = "https://dev.to/feed/tag/haskell"; title = "Haskell - dev.to"; }
+ { url = "https://devblogs.microsoft.com/typescript/feed/"; title = "TS announcements"; }
+ # { url = "https://news.ycombinator.com/rss"; title = "Hacker news"; }
+ { url = "https://mshibanami.github.io/GitHubTrendingRSS/daily/all.xml"; title = "Github trending"; }
+ { url = "https://blog.haskell.org/atom.xml"; title = "Haskell news"; }
+ ];
+
+ "Linux" = [
+ { url = "https://nixos.org/blog/announcements-rss.xml"; title = "Nixos announcements"; }
+ { url = "https://www.cyberciti.com/feed/"; title = "Cyberciti news"; }
+ { url = "https://itsfoss.com/rss/"; title = "Its FOSS"; }
+ ];
+
+ "Neovim" = [
+ { url = "https://dotfyle.com/this-week-in-neovim/rss.xml"; title = "This week in neovim"; }
+ { url = "https://dotfyle.com/neovim/plugins/rss.xml"; title = "New plugins"; }
+ { url = "https://vimtricks.com/feed/"; title = "Vimtricks"; }
+ (reddit "neovim")
+ ];
+
+ "Youtube" = [
+ (youtube "UCJswRv22oiUgmT1FuFeUekw" "IamMoBo")
+ (youtube "UCSb_Sui6FBxVS4_ROsrU_Iw" "NaturalHabitatShorts")
+ (youtube "UCR1D15p_vdP3HkrH8wgjQRw" "InternetHistorian")
+ (youtube "UC8Q7XEy86Q7T-3kNpNjYgwA" "Incognito Mode")
+ (youtube "UCW7AGm8JSBEEew61dJIgl_A" "Tom Cardy")
+ (youtube "UCh9IfI45mmk59eDvSWtuuhQ" "Ryan George")
+ (youtube "UCM15YNy8g-CaJ15YZCbq0Iw" "North of the border")
+ (youtube "UC-lHJZR3Gqxm24_Vd_AJ5Yw" "Pewdiepie")
+ (youtube "UCUMwY9iS8oMyWDYIe6_RmoA" "No boilerplate")
+ (youtube "UCo71RUe6DX4w-Vd47rFLXPg" "TypeCraft")
+ (youtube "UCWQaM7SpSECp9FELz-cHzuQ" "Dreams of code")
+ (youtube "UCjr2bPAyPV7t35MvcgT3W8Q" "The Hated One")
+ (youtube "UCimiUgDLbi6P17BdaCZpVbg" "exurb1a")
+ (youtube "UCr3cBLTYmIK9kY0F_OdFWFQ" "Casually Explained")
+ (youtube "UCYO_jab_esuFRV4b17AJtAw" "3Blue 1Brown")
+ (youtube "UCHnyfMqiRRG1u-2MsSQLbXA" "Veritasium")
+ ];
+
+ "Others" = [
+ { url = "https://xkcd.com/rss.xml"; title = "xkcd"; }
+ ];
+ };
+}
diff --git a/modules/rss/utils.nix b/modules/rss/utils.nix
new file mode 100644
index 0000000..63d09df
--- /dev/null
+++ b/modules/rss/utils.nix
@@ -0,0 +1,39 @@
+{ pkgs, lib, ... }:
+with lib;
+let
+ outlineItem = feed:
+ ''<outline title="${feed.title}" text="${feed.title}" xmlUrl="${feed.url}" />'';
+
+ outlineGroup = group: items:
+ ''<outline title="${group}" text="${group}">
+ ${concatStringsSep "\n" (map outlineItem items)}
+ </outline>'';
+
+ toOpml = cfg: ''
+<?xml version="1.0" encoding="UTF-8"?>
+<opml version="1.1">
+ <head>
+ <title>
+ ${cfg.title}
+ </title>
+ </head>
+ <body>
+ ${concatStringsSep "\n" (mapAttrsToList outlineGroup cfg.groups)}
+ </body>
+</opml>'';
+
+ createYarrSetupScript = { username, api_key, api_url, feeds, settings }:
+ let
+ api = method: path: args:
+ ''curl -i -X${method} '${api_url}${path}' --cookie 'auth=${username}:${api_key}' ${args}'';
+ opmlFile = pkgs.writeText "rss.opml" (toOpml feeds);
+ in
+ pkgs.writeShellScriptBin "yarr-setup-script" ''
+ #!/usr/bin/env sh
+
+ ${api "POST" "/opml/import" "-F 'opml=@${opmlFile}' -F 'replace=true'"} && echo "Imported feeds";
+ ${api "PUT" "/api/settings" "--data '${builtins.toJSON settings}'"} && echo "Applied settings";
+ '';
+in {
+ inherit toOpml createYarrSetupScript;
+}