{ lib, pkgs, ... }:
{

  home.shellAliases.atom = "zeditor";
  # home.shellAliases.zeditor-tail-logs = "tail -f ~/.local/share/zed/logs/Zed.log";

  home.packages = [
    # the rest are in ./remote.nix
    pkgs.unstable.zed-editor
  ];

  # setup lsp dependencies, useful for headless hosts to import too
  imports = [ ./remote.nix ];

  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" { } ''
        set -euo pipefail
        PATH="${lib.makeBinPath [ pkgs.git ]}''${PATH:+":$PATH"}"
        if [[ -e "$HOME"/.config/zed/.git ]]; then
          cd "$HOME"/.config/zed/
          git add .
          set -x
          if ! git diff --staged --exit-code --quiet; then
            git status ||:
            git commit -m "Daily auto-commit $(date -u +%Y-%m-%dT%H:%M:%S%Z) @ $(hostname)"
            git pull --rebase --autostash
            git push
          else
            git pull --rebase --autostash
          fi
        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";
  };

}
