Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions home-manager/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ with pkgs;
awscli
azure-cli
bat
broot
bun
clipse
cloudflared
Expand All @@ -27,8 +28,10 @@ with pkgs;
doppler
difftastic
direnv
doggo
duf
dust
entr
eza
fastfetch
fd
Expand All @@ -37,7 +40,9 @@ with pkgs;
gh
google-cloud-sdk
git
glow
gnumake
gping
goose-cli
grc
htop
Expand All @@ -54,21 +59,26 @@ with pkgs;
kustomize
llama-cpp
mariadb
mkcert
navi
postgresql
procs
qwen-code
ripgrep
rustup
sccache
sd
shellcheck
shellspec
speedtest-cli
sqlite
stern
tealdeer
tokei
tree
turso-cli
uv
watchexec

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's verify the files exist and check their contents
git ls-files | grep -E "(packages/default.nix|homebrew.nix)"

Repository: shunkakinoki/dotfiles

Length of output: 129


🏁 Script executed:

# Check home-manager packages file around line 81
if [ -f "home-manager/packages/default.nix" ]; then
  echo "=== home-manager/packages/default.nix (lines 75-85) ==="
  sed -n '75,85p' home-manager/packages/default.nix | cat -n
fi

Repository: shunkakinoki/dotfiles

Length of output: 286


🏁 Script executed:

# Check homebrew config around line 48
if [ -f "nix-darwin/config/homebrew.nix" ]; then
  echo "=== nix-darwin/config/homebrew.nix (lines 42-52) ==="
  sed -n '42,52p' nix-darwin/config/homebrew.nix | cat -n
fi

Repository: shunkakinoki/dotfiles

Length of output: 369


🏁 Script executed:

# Get full package lists from both files to identify all duplicates
echo "=== Extracting packages from home-manager/packages/default.nix ==="
if [ -f "home-manager/packages/default.nix" ]; then
  rg '^\s+\w[\w-]*\s*$' home-manager/packages/default.nix -o | sed 's/^\s*//' | sort | uniq > /tmp/nix_packages.txt
  echo "Total packages in home-manager/packages/default.nix:"
  wc -l /tmp/nix_packages.txt
  head -20 /tmp/nix_packages.txt
fi

echo ""
echo "=== Extracting packages from nix-darwin/config/homebrew.nix ==="
if [ -f "nix-darwin/config/homebrew.nix" ]; then
  rg '"[\w-]+"' nix-darwin/config/homebrew.nix -o | sed 's/"//g' | sort | uniq > /tmp/brew_packages.txt
  echo "Total packages in nix-darwin/config/homebrew.nix:"
  wc -l /tmp/brew_packages.txt
  head -20 /tmp/brew_packages.txt
fi

Repository: shunkakinoki/dotfiles

Length of output: 679


🏁 Script executed:

# More careful extraction to find actual duplicates
echo "=== Extracting from home-manager/packages/default.nix ==="
cat home-manager/packages/default.nix | rg '^\s+[a-z][\w-]*\s*$' -o | sed 's/^\s*//' | sort > /tmp/nix_pkgs.txt

echo "=== Extracting from nix-darwin/config/homebrew.nix ==="
# Look specifically in the brews array
sed -n '/brews = \[/,/\];/p' nix-darwin/config/homebrew.nix | rg '"([a-z][a-z0-9\-]*)"' -o | sed 's/"//g' | sort > /tmp/brew_pkgs.txt

echo "=== Finding duplicates ==="
comm -12 /tmp/nix_pkgs.txt /tmp/brew_pkgs.txt

Repository: shunkakinoki/dotfiles

Length of output: 256


🏁 Script executed:

# Show context around watchexec in both files
echo "=== watchexec in home-manager/packages/default.nix ==="
cat home-manager/packages/default.nix | rg -B2 -A2 'watchexec'

echo ""
echo "=== watchexec in nix-darwin/config/homebrew.nix ==="
cat nix-darwin/config/homebrew.nix | rg -B2 -A2 'watchexec'

Repository: shunkakinoki/dotfiles

Length of output: 287


Remove watchexec from Homebrew config; it duplicates the nixpkgs installation.

Watchexec appears in both home-manager/packages/default.nix (line 81) and nix-darwin/config/homebrew.nix (line 48). Per coding guidelines, Homebrew should only be used for macOS-specific applications. Since watchexec is a cross-platform utility, it should come from nixpkgs alone. Additionally, five other packages are duplicated across both configurations: bun, ffmpeg, gemini-cli, opencode, and postgresql. Consider auditing and removing these duplicates from one location.

🤖 Prompt for AI Agents
In home-manager/packages/default.nix around line 81, watchexec is being provided
from nixpkgs and must remain there; remove the duplicate entries (watchexec plus
bun, ffmpeg, gemini-cli, opencode, postgresql) from
nix-darwin/config/homebrew.nix (around line 48) so Homebrew only contains
macOS-specific packages; audit both files for any other duplicates, keep
cross-platform tools in nixpkgs/home-manager and delete their Homebrew entries,
and run a rebuild to verify no missing packages.

wget
yarn
yazi
Expand All @@ -90,6 +100,7 @@ with pkgs;
opencode
powertop
tailscale
trashy
]
++ lib.optionals (stdenv.isLinux && !isCI) [
chromium
Expand Down
67 changes: 43 additions & 24 deletions home-manager/services/cliproxyapi/default.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{ pkgs, ... }:
let
inherit (pkgs) lib;
# Use build-time HOME for paths that need it at plist generation
homeDir = builtins.getEnv "HOME";

# Create start script with paths substituted at build time
startScript = pkgs.replaceVars ./scripts/start.sh {
aws = "${pkgs.awscli2}/bin/aws";
sed = "${pkgs.gnused}/bin/sed";
};

# Bundle all backup scripts together
backupScripts = pkgs.runCommand "backup-scripts" { } ''
mkdir -p $out
cp ${./scripts/backup-and-recover.sh} $out/backup-and-recover.sh
cp ${./scripts/backup-auth.sh} $out/backup-auth.sh
cp ${./scripts/recover-auth.sh} $out/recover-auth.sh
chmod +x $out/*.sh
'';
# Create backup scripts with paths substituted at build time
backupAuthScript = pkgs.replaceVars ./scripts/backup-auth.sh {
aws = "${pkgs.awscli2}/bin/aws";
rsync = "${pkgs.rsync}/bin/rsync";
};
backupAndRecoverScript = pkgs.replaceVars ./scripts/backup-and-recover.sh {
bash = "${pkgs.bash}/bin/bash";
backupAuthScript = backupAuthScript;
};
in
{
# Main cliproxyapi service
Expand All @@ -27,7 +30,7 @@ in
"${startScript}"
];
Environment = {
HOME = "/Users/shunkakinoki";
HOME = homeDir;
PATH = "${
lib.makeBinPath [
pkgs.gnused
Expand Down Expand Up @@ -67,47 +70,63 @@ in
};
};

# Backup/recovery service
# Backup service with file watching for real-time sync
launchd.agents.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isDarwin {
enable = true;
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"${backupScripts}/backup-and-recover.sh"
"${backupAndRecoverScript}"
];
Environment = {
HOME = homeDir;
PATH = "${
lib.makeBinPath [
pkgs.bash
pkgs.coreutils
pkgs.awscli2
pkgs.rsync
]
}:/opt/homebrew/bin:/usr/local/bin:/usr/bin";
};
# Watch auth directories for changes - triggers sync immediately
WatchPaths = [
"${homeDir}/.cli-proxy-api/objectstore/auths"
"${homeDir}/dotfiles/objectstore/auths"
"${homeDir}/.ccs/cliproxy/auth"
];
Comment on lines +92 to 97

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep a periodic run for remote R2 updates

With StartInterval removed, this launchd job now runs only at load or when local auth directories change. The updated backup script explicitly pulls from R2 to pick up objects created remotely, but those changes won’t touch the watched local paths, so on macOS you can miss new tokens until some local write happens or the agent is reloaded. Consider restoring a periodic trigger (or another schedule) so remote-only updates are still fetched.

Useful? React with 👍 / 👎.

StartInterval = 180; # Run every 3 minutes
RunAtLoad = true;
StandardOutPath = "/tmp/cliproxyapi-backup.log";
StandardErrorPath = "/tmp/cliproxyapi-backup.error.log";
};
};

systemd.user.timers.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux {
Unit = {
Description = "CLIProxyAPI auth backup and recovery timer";
};
Timer = {
OnBootSec = "1min";
OnUnitActiveSec = "3min";
systemd.user.paths.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux {
Unit.Description = "Watch auth directories for changes";
Path = {
PathChanged = [
"%h/.cli-proxy-api/objectstore/auths"
"%h/dotfiles/objectstore/auths"
"%h/.ccs/cliproxy/auth"
];
Unit = "cliproxyapi-backup.service";
};
Install = {
WantedBy = [ "timers.target" ];
};
Install.WantedBy = [ "paths.target" ];
};

systemd.user.services.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux {
Unit = {
Description = "CLIProxyAPI auth backup and recovery";
Description = "CLIProxyAPI auth backup";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash ${backupScripts}/backup-and-recover.sh";
ExecStart = "${pkgs.bash}/bin/bash ${backupAndRecoverScript}";
Environment = "PATH=${
lib.makeBinPath [
pkgs.bash
pkgs.awscli2
pkgs.coreutils
pkgs.rsync
]
}";
};
Expand Down
15 changes: 4 additions & 11 deletions home-manager/services/cliproxyapi/scripts/backup-and-recover.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/usr/bin/env bash
# Combined backup and recovery script
# Backs up auth files to R2, then recovers if missing
# Backup auth files to R2 (pull-first ensures recovery is handled)

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Source .env for credentials
if [ -f "$HOME/dotfiles/.env" ]; then
set -a
Expand All @@ -14,12 +11,8 @@ if [ -f "$HOME/dotfiles/.env" ]; then
set +a
fi

# Run backup
# Run backup (handles recovery via pull-first)
echo "[$(date)] Starting backup..."
"$SCRIPT_DIR/backup-auth.sh"

# Run recovery if needed
echo "[$(date)] Checking for recovery..."
"$SCRIPT_DIR/recover-auth.sh"
@bash@ @backupAuthScript@

echo "[$(date)] Backup/recovery cycle complete"
echo "[$(date)] Backup complete"
77 changes: 59 additions & 18 deletions home-manager/services/cliproxyapi/scripts/backup-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,74 @@ BACKUP_DIR="s3://cliproxyapi/backup/auths/"
MAIN_DIR="s3://cliproxyapi/auths/"
AUTH_DIR="$CONFIG_DIR/objectstore/auths"
DOTFILES_AUTH_DIR="$HOME/dotfiles/objectstore/auths"
CCS_AUTH_DIR="$HOME/.ccs/cliproxy/auth"

# First, sync from dotfiles repo to local cache (picks up new auth files from ccs auth)
# STEP 1: Pull from R2 to local (captures files created by cliproxyapi directly in R2)
mkdir -p "$AUTH_DIR"
if [ -n "${OBJECTSTORE_ENDPOINT:-}" ]; then
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$MAIN_DIR" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The aws s3 sync command suppresses all error messages by redirecting stderr to /dev/null and ignores the exit code with || true. This can hide critical failures (e.g., invalid credentials, network issues) and make debugging very difficult. Please remove the error suppression to allow errors to be logged. If the intent is to continue on failure, you can still log the error message.

Suggested change
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || true
"$AUTH_DIR/" && echo "✅ Pulled from R2 auths/" >&2 || echo "⚠️ Pull from R2 auths/ failed: $?" >&2


# Also pull from backup location to ensure we have all files
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$BACKUP_DIR" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the previous s3 sync command, this one also suppresses all error messages. This can hide critical failures. Please remove the error suppression to allow errors to be logged for easier debugging.

Suggested change
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true
"$AUTH_DIR/" && echo "✅ Pulled from R2 backup/auths/" >&2 || echo "⚠️ Pull from R2 backup/auths/ failed: $?" >&2

Comment on lines +17 to +32

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backup script pulls from both MAIN_DIR and BACKUP_DIR in sequence (lines 17-32), syncing both to the same AUTH_DIR. If MAIN_DIR has newer files and BACKUP_DIR has older versions of the same files, the older versions from BACKUP_DIR will overwrite the newer ones from MAIN_DIR. Consider using rsync with --ignore-existing or --update flag, or restructure the logic to only pull from BACKUP_DIR when MAIN_DIR sync fails or is empty.

Suggested change
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$MAIN_DIR" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || true
# Also pull from backup location to ensure we have all files
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$BACKUP_DIR" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true
MAIN_SYNC_STATUS=0
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$MAIN_DIR" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || MAIN_SYNC_STATUS=$?
# Fallback: pull from backup location only if main sync failed or produced no files
if [ "$MAIN_SYNC_STATUS" -ne 0 ] || [ -z "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$BACKUP_DIR" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true
fi

Copilot uses AI. Check for mistakes.
fi

# STEP 2: Sync from dotfiles repo to local cache (picks up new auth files from ccs auth)
if [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then
mkdir -p "$AUTH_DIR"
rsync -a "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
@rsync@ -a "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Synced from dotfiles repo to local cache" >&2
fi

# STEP 2b: Sync from ccs auth dir (picks up files created by ccs's internal cliproxy)

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "STEP 2b" but the previous step is "STEP 2", not "STEP 2a". The numbering scheme should either use STEP 3 or change STEP 2 to STEP 2a for consistency.

Copilot uses AI. Check for mistakes.
if [ -d "$CCS_AUTH_DIR" ] && [ -n "$(ls -A "$CCS_AUTH_DIR" 2>/dev/null)" ]; then
@rsync@ -a "$CCS_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Synced from ccs auth dir to local cache" >&2
fi

# Check if auth directory has files
if [ -d "$AUTH_DIR" ] && [ -n "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then
echo "Syncing auth files to R2..." >&2

# Sync to main auths/ location (what cliproxyapi reads from)
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
aws s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$MAIN_DIR" 2>/dev/null && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed" >&2
if [ -z "${OBJECTSTORE_ENDPOINT:-}" ]; then
echo "⚠️ OBJECTSTORE_ENDPOINT not set, skipping R2 sync" >&2
else
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed: $?" >&2
Comment on lines +55 to +61

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Bug: $? will be 0 after the echo command.

The $? in the error message will always reflect the exit status of the preceding echo command (which is 0), not the failed AWS sync. Capture the exit code before reporting.

🔎 Proposed fix
     AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
       AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
       @aws@ s3 sync \
       --endpoint-url="${OBJECTSTORE_ENDPOINT}" \
       --no-progress \
       "$AUTH_DIR/" \
-      "$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || echo "⚠️  Sync to auths/ failed: $?" >&2
+      "$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || { rc=$?; echo "⚠️  Sync to auths/ failed: $rc" >&2; }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed: $?" >&2
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || { rc=$?; echo "⚠️ Sync to auths/ failed: $rc" >&2; }
🤖 Prompt for AI Agents
In home-manager/services/cliproxyapi/scripts/backup-auth.sh around lines 55 to
61, the error message uses `$?` after an `echo`, so it reports the echo's exit
status (0) instead of the AWS sync exit code; immediately capture the aws s3
sync exit status into a variable right after the sync command (e.g., rc=$?),
then use that variable in the subsequent conditional/echo to report the actual
failure code and preserve original redirection to stderr.

Comment on lines +55 to +61

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message prints the exit code "$?" which will always be 0 in this context because the echo command itself succeeds. The exit code from the aws s3 sync command is lost due to the || operator. Consider capturing the exit code before the || operator or restructure the error handling to properly report the actual failure code.

Suggested change
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed: $?" >&2
if AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$MAIN_DIR"; then
echo "✅ Synced to auths/" >&2
else
echo "⚠️ Sync to auths/ failed: $?" >&2
fi

Copilot uses AI. Check for mistakes.

# Also sync to backup location for redundancy
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
aws s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$BACKUP_DIR" 2>/dev/null && echo "✅ Synced to backup/auths/" >&2 || echo "⚠️ Backup sync failed" >&2
# Also sync to backup location for redundancy
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$BACKUP_DIR" && echo "✅ Synced to backup/auths/" >&2 || echo "⚠️ Backup sync failed" >&2
Comment on lines +61 to +70

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message for the backup sync failure on line 70 does not include the exit code, unlike the main sync failure message on line 61. For consistency and better debugging, it's helpful to include the exit code ($?) in all failure messages.

Suggested change
"$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed: $?" >&2
# Also sync to backup location for redundancy
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
aws s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$BACKUP_DIR" 2>/dev/null && echo "✅ Synced to backup/auths/" >&2 || echo "⚠️ Backup sync failed" >&2
# Also sync to backup location for redundancy
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$BACKUP_DIR" && echo "✅ Synced to backup/auths/" >&2 || echo "⚠️ Backup sync failed" >&2
"$MAIN_DIR" && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed: $?" >&2
# Also sync to backup location for redundancy
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"$AUTH_DIR/" \
"$BACKUP_DIR" && echo "✅ Synced to backup/auths/" >&2 || echo "⚠️ Backup sync failed: $?" >&2

fi

# Sync to ccs auth dir (so ccs can find the tokens)
mkdir -p "$CCS_AUTH_DIR"
@rsync@ -a "$AUTH_DIR/" "$CCS_AUTH_DIR/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure that the ccs auth directory is an exact mirror of the local cache, consider adding the --delete flag to rsync. This will remove any files in the destination that are no longer present in the source, which is useful for propagating token deletions.

Suggested change
@rsync@ -a "$AUTH_DIR/" "$CCS_AUTH_DIR/"
@rsync@ -a --delete "$AUTH_DIR/" "$CCS_AUTH_DIR/"

echo "✅ Synced to ccs auth dir" >&2

# Also sync back to dotfiles repo for git tracking
mkdir -p "$DOTFILES_AUTH_DIR"
@rsync@ -a "$AUTH_DIR/" "$DOTFILES_AUTH_DIR/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly, to ensure the dotfiles auth directory is an exact mirror of the local cache for git tracking, consider adding the --delete flag to rsync. This will ensure that deleted tokens are also removed from the dotfiles repository.

Suggested change
@rsync@ -a "$AUTH_DIR/" "$DOTFILES_AUTH_DIR/"
@rsync@ -a --delete "$AUTH_DIR/" "$DOTFILES_AUTH_DIR/"

echo "✅ Synced to dotfiles repo" >&2
Comment on lines +73 to +81

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backup script now syncs auth files back to the CCS auth directory and dotfiles directory even when OBJECTSTORE_ENDPOINT is not set, which means it could sync stale/incomplete data. These sync operations (lines 73-81) should only execute when the R2 sync succeeds, or at minimum when OBJECTSTORE_ENDPOINT is set, to ensure data consistency across all locations.

Copilot uses AI. Check for mistakes.
fi
37 changes: 0 additions & 37 deletions home-manager/services/cliproxyapi/scripts/recover-auth.sh

This file was deleted.

1 change: 1 addition & 0 deletions nix-darwin/config/homebrew.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"postgresql"
"postgresql@18"
"protobuf"
"pulumi"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if pulumi is available in nixpkgs
nix search nixpkgs pulumi --json 2>/dev/null | jq 'keys' || echo "Search failed or pulumi not found"

Repository: shunkakinoki/dotfiles

Length of output: 47


🏁 Script executed:

#!/bin/bash
# Examine the file context around line 43
if [ -f "nix-darwin/config/homebrew.nix" ]; then
  echo "=== File context around line 43 ==="
  head -n 50 nix-darwin/config/homebrew.nix | tail -n 20
else
  echo "File not found at nix-darwin/config/homebrew.nix"
  find . -name "homebrew.nix" -type f 2>/dev/null
fi

Repository: shunkakinoki/dotfiles

Length of output: 418


🏁 Script executed:

#!/bin/bash
# Check file structure
echo "=== Full homebrew.nix structure ==="
cat -n nix-darwin/config/homebrew.nix

Repository: shunkakinoki/dotfiles

Length of output: 2943


🏁 Script executed:

#!/bin/bash
# Try different approaches to find pulumi in nixpkgs
echo "=== Search for pulumi in nixpkgs registry ==="
nix-env -qa 'pulumi' 2>/dev/null || echo "nix-env search unavailable"

echo ""
echo "=== Check flake inputs or nixpkgs references ==="
if [ -f "flake.nix" ]; then
  grep -A5 -B5 "nixpkgs" flake.nix | head -20
fi

Repository: shunkakinoki/dotfiles

Length of output: 678


🌐 Web query:

pulumi cross-platform availability nixpkgs nixos

💡 Result:

Short answer — Pulumi is cross‑platform and available in nixpkgs/NixOS.

  • Pulumi upstream provides prebuilt binaries for macOS, Linux and Windows (x86_64 and arm variants) and an install script. [1]
  • Nixpkgs packages Pulumi (pulumi, pulumi-bin) and many Pulumi language hosts/providers (nodejs, python, providers/plugins) so you can install via NixOS/nix-env, flakes, or Devbox; the nixpkgs entries list many platforms supported by the Nix build. [2][3]

If you want specific nixpkgs package names or an example NixOS/flake snippet to install Pulumi, tell me which language/runtime (CLI only, nodejs, python, etc.) and whether you prefer flake or legacy config and I’ll provide it.

Sources:
[1] Pulumi — Download & Install.
[2] pulumi package in nixpkgs (MyNixOS listing).
[3] pulumi-bin / pulumiPackages entries (NixHub / package index).


Move pulumi from Homebrew to nixpkgs.

Pulumi is a cross-platform tool with packages available for macOS, Linux, and Windows. It is available in nixpkgs and should be installed via nixpkgs instead of Homebrew to follow the guideline that Homebrew should only be used for macOS-specific applications.

🤖 Prompt for AI Agents
In nix-darwin/config/homebrew.nix around line 43, the package "pulumi" is
currently listed under Homebrew; remove "pulumi" from the Homebrew package list
and add it to the nixpkgs package set instead (e.g., include it in your
system/nixpkgs packages or environment.systemPackages where other cross-platform
tools are declared). Update any imports/overrides so pulumi is installed from
nixpkgs (not brew), and ensure the Homebrew list contains only macOS-specific
apps afterward.

"reth"
"sheldon"
"sshpass"
Expand Down
Loading
Loading