helm/home/profiles/sync/kitaab/default.nix

40 lines
1.1 KiB
Nix
Raw Permalink Normal View History

{ 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
2024-01-05 23:43:01 -08:00
PATH=/run/current-system/sw/bin:/etc/profiles/per-user/anish/bin:$PATH
cd /home/anish/kitaab/vimwiki
vimwiki tags rebuild
2024-01-05 23:43:01 -08:00
cd ..
pushd kalpana/
2024-01-05 23:43:01 -08:00
${pkgs.luaPackages.fennel}/bin/fennel main.fnl build
popd
pushd vimwiki/
git add -A .
popd
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}";
2024-01-05 23:43:01 -08:00
Path = [ pkgs.luaPackages.fennel ];
};
};
systemd.user.timers.kitaab-sync = {
Install = {
WantedBy = [ "timers.target" ];
PartOf = [ "kitaab-sync.service" ];
};
Timer = {
OnCalendar = [ "hourly" ];
};
};
}