From 395f580645b2e676419039da1e90a0df9e85c4a8 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 10 Jun 2026 23:06:43 -0700 Subject: [PATCH] nixos: add git-sync service for claude-history repo Syncs ~/.claude to github.com/colonelpanic8/claude-history on ryzen-shine and railbird-sf. Uses git-sync-rs in watch mode with --new-files true and a 300s min-interval to handle active sessions appending to transcripts without spamming pushes. Co-Authored-By: Claude Sonnet 4.6 --- dotfiles/claude/.gitignore | 6 ------ nixos/git-sync.nix | 34 ++++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) delete mode 100644 dotfiles/claude/.gitignore diff --git a/dotfiles/claude/.gitignore b/dotfiles/claude/.gitignore deleted file mode 100644 index a08d446f..00000000 --- a/dotfiles/claude/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -* -!.gitignore -!CLAUDE.md -!settings.json -!settings.local.json -!settings.local.json.example diff --git a/nixos/git-sync.nix b/nixos/git-sync.nix index 8597b7d1..c97d1e63 100644 --- a/nixos/git-sync.nix +++ b/nixos/git-sync.nix @@ -1,9 +1,15 @@ { pkgs, lib, + config, ... }: let gitSyncServicePath = lib.makeBinPath [pkgs.coreutils pkgs.git pkgs.openssh]; + # ~/.claude history sync is being rolled out machine-by-machine; each new + # machine needs its existing history merged into the repo first (see + # github.com/colonelpanic8/claude-history). + claudeHistoryHosts = ["ryzen-shine" "railbird-sf"]; + syncClaudeHistory = builtins.elem config.networking.hostName claudeHistoryHosts; mkGitSyncTrayOverrides = icon: { Service = { Environment = lib.mkMerge [ @@ -33,15 +39,31 @@ in { path = config.home.homeDirectory + "/.password-store"; uri = "git@github.com:IvanMalison/.password-store.git"; }; + } + // lib.optionalAttrs syncClaudeHistory { + claude-history = { + path = config.home.homeDirectory + "/.claude"; + uri = "git@github.com:colonelpanic8/claude-history.git"; + interval = 600; + }; }; }; - systemd.user.services = - lib.mapAttrs' - (name: _: - lib.nameValuePair "git-sync-${name}" - (mkGitSyncTrayOverrides (repoIcons.${name} or "git"))) - config.services.git-sync.repositories; + systemd.user.services = lib.mkMerge [ + (lib.mapAttrs' + (name: _: + lib.nameValuePair "git-sync-${name}" + (mkGitSyncTrayOverrides (repoIcons.${name} or "git"))) + config.services.git-sync.repositories) + (lib.optionalAttrs syncClaudeHistory { + # Live sessions append to their transcript on every message; sync + # untracked session files and throttle event-driven syncs so an + # active session doesn't push once per append. + git-sync-claude-history.Service.ExecStart = + lib.mkForce + "${pkgs.git-sync-rs}/bin/git-sync-rs watch --new-files true --min-interval 300"; + }) + ]; }; home-manager.users.kat = {config, ...}: {