From c508e290c739e7398d19cb3c289b563716d8b94b Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Mon, 17 Mar 2025 00:25:30 +0100 Subject: [PATCH] sync config --- .../home/profiles/desktop/zed/default.nix | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/users/pbsds/home/profiles/desktop/zed/default.nix b/users/pbsds/home/profiles/desktop/zed/default.nix index b79d075..8df2874 100644 --- a/users/pbsds/home/profiles/desktop/zed/default.nix +++ b/users/pbsds/home/profiles/desktop/zed/default.nix @@ -10,10 +10,35 @@ imports = [ ./remote.nix ]; - # TODO: - #.config/zed/keymap.json - #.config/zed/settings.json - #.config/zed/themes - #.config/zed/snippets + systemd.user.services."update-zed-config" = { + Unit.Description = "Autoupdate zed config"; + Service.Type = "oneshot"; + Service.ExecStart = toString ( + # TODO: do I want to clone it if missing? Requires git keys, I should clone on OnActiveSec + pkgs.writers.writeBash "update-zed-config" { } '' + PATH="${lib.makeBinPath [ pkgs.git ]}''${PATH:-":$PATH"}" + if [[ -e "$HOME".config/zed/.git ]]; then + cd "$HOME".config/zed/ + git add . + if ! git diff --staged --exit-code --quiet; then + git commit -m "Daily auto-commit $(date -u +%Y-%m-%dT%H:%M:%S%Z) @ $(hostname)" + fi + git pull --rebase --autostash + git push + fi + '' + ); + }; + systemd.user.timers."update-zed-config" = { + Unit.Description = "Autoupdate zed config"; + Install.WantedBy = [ "timers.target" ]; + # https://www.man7.org/linux/man-pages/man5/systemd.timer.5.html + # Timer.OnBootSec = "10m"; + # Timer.OnUnitActiveSec = "24h"; + # Timer.Persistent = true; # will remember to do a thing on boot if timer was missed while off + Timer.OnCalendar = "06:00"; + Timer.RandomizedDelaySec = "45min"; + Timer.Unit = "update-zed-config.service"; + }; }