2024-04-14 04:20:56 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2022-05-05 23:01:56 -04:00
|
|
|
|
2025-01-30 14:48:17 -05:00
|
|
|
let
|
|
|
|
cfg = config.nmasur.presets.services.notes-git-sync;
|
|
|
|
in
|
2023-07-30 20:26:23 -04:00
|
|
|
|
2025-01-30 14:48:17 -05:00
|
|
|
{
|
|
|
|
options.nmasur.presets.services.notes-git-sync.enable = lib.mkEnableOption "Sync notes to folder";
|
2022-05-01 23:39:50 -04:00
|
|
|
|
2025-01-30 14:48:17 -05:00
|
|
|
config = lib.mkIf cfg.enable {
|
2022-05-01 23:39:50 -04:00
|
|
|
|
2024-04-14 04:20:56 +00:00
|
|
|
# Sync notes for Nextcloud automatically
|
2025-01-30 14:48:17 -05:00
|
|
|
systemd.user.timers.refresh-notes = {
|
2024-04-14 04:20:56 +00:00
|
|
|
Timer = {
|
|
|
|
OnCalendar = "*-*-* *:0/10:50"; # Every 10 minutes
|
|
|
|
Unit = "refresh-notes.service";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
systemd.user.services.refresh-notes = {
|
|
|
|
Unit.Description = "Get latest notes.";
|
|
|
|
Service = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStartPre = "${pkgs.git}/bin/git -C /data/git/notes reset --hard master";
|
|
|
|
ExecStart = "${pkgs.git}/bin/git -C /data/git/notes pull";
|
|
|
|
WorkingDirectory = config.homePath;
|
|
|
|
Environment = "PATH=${pkgs.openssh}/bin";
|
|
|
|
};
|
|
|
|
};
|
2022-05-01 23:39:50 -04:00
|
|
|
};
|
|
|
|
}
|