helm/home/profiles/sync/kitaab/default.nix
Anish Lakhwara 335361c496 feat(curve): add kalpana to production
it generates backlinks and indexs in a more reliable way
2023-11-05 01:31:36 -07:00

38 lines
1 KiB
Nix

{ 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" ''
# 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
PATH=/run/current-system/sw/bin:/etc/profiles/per-user/anish/bin:
cd /home/anish/kitaab
vimwiki tags rebuild
# python3 poonam/main.py generateindexs
# python3 poonam/main.py generatebacklinks
pushd kalpana/
fennel main.fnl
popd
git add -A ./vimwiki/
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" ];
};
};
}