From 00c5b668482614254df95e617396c787cf66e8f6 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 16 Mar 2025 18:22:51 +0100 Subject: ... --- accounts/gkleen@sif/systemd.nix | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'accounts/gkleen@sif/systemd.nix') diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index 99cbcbb3..48352208 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -46,11 +46,11 @@ in { ]; services = { - sync-keepass = { + "sync-keepass@" = { Service = { Type = "oneshot"; WorkingDirectory = "~"; - ExecStart = toString (pkgs.writers.writePython3 "sync-keepass" { + ExecStart = "${pkgs.writers.writePython3 "sync-keepass" { libraries = with pkgs.python3Packages; [ python-dateutil ]; } '' import json @@ -59,13 +59,13 @@ in { from datetime import datetime from dateutil.tz import tzlocal from dateutil.parser import isoparse - from sys import stderr + from sys import stderr, argv - remote_fs = 'surtr' - remote_file = 'store.kdbx' - target_file = expanduser('~/store.kdbx') - meta_file = expanduser('~/.store.kdbx.json') + remote_fs = 'surtr' if argv[1] == 'store.kdbx' else 'mathcloud' + remote_file = argv[1] + target_file = expanduser(f'~/{argv[1]}') + meta_file = expanduser(f'~/.{argv[1]}.json') upload_time = None our_last_upload_time = None @@ -115,7 +115,7 @@ in { do_upload() elif upload_time is not None and (mod_time is None or upload_time > mod_time) and (our_last_upload_time is None or upload_time > our_last_upload_time): # noqa: E501 do_download() - ''); + ''} \"%I\""; Environment = [ "RCLONE_PASSWORD_COMMAND=\"${pkgs.coreutils}/bin/cat ${config.sops.secrets.gkleen-rclone.path}\"" "PATH=${pkgs.rclone}/bin" ]; }; }; @@ -408,12 +408,22 @@ in { }; }; timers = { - sync-keepass = { + "sync-keepass@store.kdbx" = { Timer = { OnActiveSec = "1m"; OnUnitActiveSec = "1m"; }; + Install = { + WantedBy = ["default.target"]; + }; + }; + "sync-keepass@rz.kdbx" = { + Timer = { + OnActiveSec = "3h"; + OnUnitActiveSec = "3h"; + }; + Install = { WantedBy = ["default.target"]; }; -- cgit v1.2.3