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 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 23:06:43 -07:00
parent a957e78e25
commit 395f580645
2 changed files with 28 additions and 12 deletions

View File

@@ -1,6 +0,0 @@
*
!.gitignore
!CLAUDE.md
!settings.json
!settings.local.json
!settings.local.json.example

View File

@@ -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, ...}: {