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:
6
dotfiles/claude/.gitignore
vendored
6
dotfiles/claude/.gitignore
vendored
@@ -1,6 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
!CLAUDE.md
|
|
||||||
!settings.json
|
|
||||||
!settings.local.json
|
|
||||||
!settings.local.json.example
|
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
gitSyncServicePath = lib.makeBinPath [pkgs.coreutils pkgs.git pkgs.openssh];
|
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: {
|
mkGitSyncTrayOverrides = icon: {
|
||||||
Service = {
|
Service = {
|
||||||
Environment = lib.mkMerge [
|
Environment = lib.mkMerge [
|
||||||
@@ -33,15 +39,31 @@ in {
|
|||||||
path = config.home.homeDirectory + "/.password-store";
|
path = config.home.homeDirectory + "/.password-store";
|
||||||
uri = "git@github.com:IvanMalison/.password-store.git";
|
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 =
|
systemd.user.services = lib.mkMerge [
|
||||||
lib.mapAttrs'
|
(lib.mapAttrs'
|
||||||
(name: _:
|
(name: _:
|
||||||
lib.nameValuePair "git-sync-${name}"
|
lib.nameValuePair "git-sync-${name}"
|
||||||
(mkGitSyncTrayOverrides (repoIcons.${name} or "git")))
|
(mkGitSyncTrayOverrides (repoIcons.${name} or "git")))
|
||||||
config.services.git-sync.repositories;
|
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, ...}: {
|
home-manager.users.kat = {config, ...}: {
|
||||||
|
|||||||
Reference in New Issue
Block a user