2023-05-22 04:58:12 -07:00
|
|
|
{ pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
name = "kitaab-sync";
|
|
|
|
# Note this will fail if index.wiki is open in vim while this runs
|
|
|
|
mkStartScript = name: pkgs.writeShellScript "${name}.sh" ''
|
2023-05-30 05:29:26 -07:00
|
|
|
# set -euo pipefail # Sometimes vimwiki is open and that causes `vimwiki tags rebuild` to fail, we still want to push to git in those cases
|
2023-05-22 04:58:12 -07:00
|
|
|
PATH=/run/current-system/sw/bin:/etc/profiles/per-user/anish/bin:
|
|
|
|
cd /home/anish/kitaab
|
|
|
|
vimwiki tags rebuild
|
2023-06-03 04:47:44 -07:00
|
|
|
python3 poonam/main.py generateindexs
|
2023-08-12 17:08:52 -07:00
|
|
|
python3 poonam/main.py generatebacklinks
|
|
|
|
git add -A ./vimwiki/
|
2023-05-22 04:58:12 -07:00
|
|
|
git diff-index --quiet HEAD || git commit -m 'syncing kitaab' # if nothing, don't exit 1
|
|
|
|
git push
|
|
|
|
exit 0
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
systemd.user.services.kitaab-sync = {
|
|
|
|
Service = {
|
|
|
|
ExecStart = "${mkStartScript name}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
systemd.user.timers.kitaab-sync = {
|
|
|
|
Install = {
|
|
|
|
WantedBy = [ "timers.target" ];
|
|
|
|
PartOf = [ "kitaab-sync.service" ];
|
|
|
|
};
|
|
|
|
Timer = {
|
|
|
|
OnCalendar = [ "hourly" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|