diff options
author | stuebinm | 2022-01-23 20:22:29 +0100 |
---|---|---|
committer | stuebinm | 2022-01-24 00:05:38 +0100 |
commit | e38940da43801c22f7ece69a3a00aae709610327 (patch) | |
tree | 3b38d779923c7c50980bc1f3b0c37b39bfd3dbc4 /home | |
parent | 5f532cabbfc02dcab366e5b83b261b386d128b96 (diff) |
add almanac / ical feed syncing
Diffstat (limited to 'home')
-rw-r--r-- | home/home.nix | 20 | ||||
-rw-r--r-- | home/packages.nix | 5 | ||||
-rwxr-xr-x | home/scripts/sync.scm | 28 |
3 files changed, 49 insertions, 4 deletions
diff --git a/home/home.nix b/home/home.nix index f2a0f7e..57aa9b2 100644 --- a/home/home.nix +++ b/home/home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, inputs, ... }: +{ config, lib, pkgs, inputs, ... }: { # Let Home Manager install and manage itself. @@ -86,6 +86,7 @@ ll = "exa -lh --grid --icons"; llt = "exa -lh --tree --icons"; lt = "exa --tree --icons"; + agenda = "almanac month ~/.cache/feedsync/*"; }; functions = { fish_greeting = { @@ -94,9 +95,24 @@ }; }; + systemd.user.services.syncical = let + feeds = (import inputs.feeds).ical; in { + Unit.Description = "syncs ical feeds for almanac agenda"; + Service.ExecStart = "${./scripts/sync.scm} ${lib.fold (a: b: a + " " + b) "" feeds}"; + }; + + systemd.user.timers.syncical = { + Unit.Description = "automatically fetch new calendars"; + Timer = { + OnCalendar = "hourly"; + Unit = "syncical.service"; + }; + Install.WantedBy = [ "timers.target" ]; + }; + programs.newsboat = { enable = true; - urls = (import ./newsboat-public.nix) ++ (import inputs.feeds); + urls = (import ./newsboat-public.nix) ++ (import inputs.feeds).rss; browser = pkgs.lynx.outPath + "/bin/lynx"; reloadThreads = 100; queries = { diff --git a/home/packages.nix b/home/packages.nix index 6182ad3..e408c21 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -4,6 +4,7 @@ let naersk = pkgs.callPackage inputs.naersk {}; extras = { sfz = naersk.buildPackage inputs.sfz; + almanac = naersk.buildPackage inputs.almanac; leylines = pkgs.callPackage "${(pkgs.fetchgit { url = "https://gitlab.infra4future.de/stuebinm/leylines"; sha256 = "sha256-zhUYAqa8qEa+2VvLU2/BRQ/0RV95/3UTU/nvybopZ7A="; @@ -44,7 +45,7 @@ in tree dnsutils inetutils pijul bat age libsecret gping bottom dogdns cifs-utils jekyll fzf ripgrep fd bandwhich exa dive ripgrep python39Packages.isort shellcheck graphviz - poppler unzip acpi extras.sfz viu extras.leylines + poppler unzip acpi extras.sfz extras.almanac viu extras.leylines youtube-dl # git gitAndTools.gitAnnex git-bug git-appraise @@ -57,7 +58,7 @@ in haskellPackages.hoogle haskellPackages.stylish-haskell # other functional things racket dhall lean dune_2 ocamlPackages.utop ocamlPackages.ocp-indent - ocamlPackages.merlin ocaml + ocamlPackages.merlin ocaml gauche # html, js & co jq html-tidy nodePackages.stylelint nodePackages.js-beautify zola # purescript diff --git a/home/scripts/sync.scm b/home/scripts/sync.scm new file mode 100755 index 0000000..a51b557 --- /dev/null +++ b/home/scripts/sync.scm @@ -0,0 +1,28 @@ +#!/usr/bin/env gosh + +;; download the given files to ~/.cache/feedsync under hashed filenames +;; if the versions there are older than two hours + +(use util.match) +(use gauche.process) + + +(define targets + (cdr (command-line))) + +(define cachedir + (string-append (sys-getenv "HOME") "/.cache/feedsync")) + +(do-process `("mkdir" "-p" ,cachedir)) + +(map (lambda (target) + (let ([cachefile (format "~a/~a.ics" cachedir (portable-hash target 0))]) + (cond + [(not (file-exists? cachefile)) + (do-process `("curl" ,target "-o" ,cachefile))] + [(< 7200 (- (sys-time) (sys-stat->mtime (sys-stat cachefile)))) + (print (format "fetching ~a" target)) + (do-process `("curl" ,target "-o" ,cachefile))] + [else + (display "time limit not yet exceeded")]))) + targets) |