Commit 8db075b9930b
Changed files (3)
home
common
services
home/common/services/readwise-sync.nix
@@ -0,0 +1,67 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+with lib;
+
+let
+ cfg = config.services.readwise-sync;
+
+ readwise-sync-wrapper = pkgs.writeShellScriptBin "readwise-sync" ''
+ set -euo pipefail
+
+ READWISE_KEY=$(${pkgs.passage}/bin/passage show readwise/key)
+ export READWISE_KEY
+
+ ${pkgs.go-org-readwise}/bin/go-org-readwise \
+ -archiveURLs=true \
+ -targetFolder ${cfg.targetFolder}
+ '';
+in
+{
+ options.services.readwise-sync = {
+ enable = mkEnableOption "automatic Readwise to org-mode sync";
+
+ targetFolder = mkOption {
+ type = types.str;
+ default = "${config.home.homeDirectory}/desktop/org/notes";
+ description = "Target folder for synced org files";
+ };
+
+ interval = mkOption {
+ type = types.str;
+ default = "daily";
+ description = "How often to sync (systemd timer format)";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = [ readwise-sync-wrapper ];
+
+ systemd.user.services.readwise-sync = {
+ Unit = {
+ Description = "Sync Readwise highlights to org-mode files";
+ };
+ Service = {
+ Type = "oneshot";
+ ExecStart = "${readwise-sync-wrapper}/bin/readwise-sync";
+ };
+ };
+
+ systemd.user.timers.readwise-sync = {
+ Unit = {
+ Description = "Timer for syncing Readwise to org-mode";
+ };
+ Timer = {
+ OnCalendar = cfg.interval;
+ Persistent = true;
+ };
+ Install = {
+ WantedBy = [ "timers.target" ];
+ };
+ };
+ };
+}
systems/aomi/home.nix
@@ -9,6 +9,7 @@
../../home/common/dev/containers.nix
../../home/common/dev/tektoncd.nix
../../home/common/desktop/passage.nix
+ ../../home/common/services/readwise-sync.nix
../../home/common/shell/gh.nix
];
systemd.user.services.syncthing.Install.WantedBy = [ "multi-user.target" ];
@@ -30,6 +31,12 @@
lazygit
];
+ # Readwise sync to org-mode
+ services.readwise-sync = {
+ enable = true;
+ interval = "daily";
+ };
+
# Passage update service and timer
systemd.user.services.passage-update = {
Unit = {
systems/kyushu/home.nix
@@ -17,6 +17,7 @@ in
../../home/common/services/gcal-to-org.nix
../../home/common/services/goimapnotify.nix
../../home/common/services/mail-monitor.nix
+ ../../home/common/services/readwise-sync.nix
../../home/common/services/redhat.nix
../../home/common/shell/gh.nix
];
@@ -99,6 +100,12 @@ in
interval = "hourly";
};
+ # Readwise sync to org-mode
+ services.readwise-sync = {
+ enable = true;
+ interval = "daily";
+ };
+
# ntfy notification subscriber
systemd.user.services.ntfy-subscriber = {
Unit = {