Refactor SSH agent keychain integration for Linux - #426
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the SSH agent keychain integration for Linux by simplifying the key loading logic. It removes the automatic loading of a GitHub-specific SSH key while retaining the default key loading mechanism.
Key Changes:
- Removed automatic loading of
~/.ssh/id_ed25519_githubkey - Updated comment to remove the "(no passphrase)" note from the default key loading section
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughRemoved GitHub-specific SSH key auto-loading; moved Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Scheduler as Scheduler (launchd / systemd.timer)
participant BackupScript as backup-and-recover.sh
participant BackupWorker as backup-auth.sh
participant RecoverWorker as recover-auth.sh
participant ObjectStore as S3-compatible object store
Note over Scheduler,BackupScript: periodic trigger (every 5 minutes)
Scheduler ->> BackupScript: Execute
BackupScript ->> BackupWorker: run backup-auth.sh (if present & executable)
BackupWorker ->> ObjectStore: aws s3 sync AUTH_DIR → BACKUP_DIR
BackupWorker -->> BackupScript: return (success / warning)
BackupScript ->> RecoverWorker: run recover-auth.sh (if present & executable)
RecoverWorker ->> ObjectStore: aws s3 sync BACKUP_DIR → AUTH_DIR (if missing/empty)
RecoverWorker -->> BackupScript: return (restored / none)
BackupScript -->> Scheduler: exit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the SSH agent keychain integration for Linux by streamlining the key loading process and updating the file structure. The primary goal is to simplify how SSH keys are managed and loaded into the agent, making the configuration cleaner and more focused on default key handling. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
You do not have enough credits to review this pull request. Please purchase more credits to continue. |
Mesa DescriptionTL;DRSimplified Linux SSH agent keychain integration by loading only the default key. Introduced robust backup and recovery for What changed?
Description generated by Mesa. Update settings |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
home-manager/services/ssh-agent/default.nix(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.nix
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.nix: Use nixfmt for formatting all Nix files
Document complex configurations with comments in Nix files
**/*.nix: Use 2 spaces for indentation in Nix files
Keep line length under 100 characters in Nix files
Sort attribute sets alphabetically in Nix files
Use consistent spacing around operators in Nix files
Format lists and sets consistently in Nix filesUse treefmt.toml for formatting Nix files
**/*.nix: UsemkOptionfor configurable options in Nix modules
Implement proper typing for all options in Nix modules
Follow the Nix expression language style guide
Files:
home-manager/services/ssh-agent/default.nix
**/default.nix
📄 CodeRabbit inference engine (CLAUDE.md)
Use
default.nixfiles for module exports
Files:
home-manager/services/ssh-agent/default.nix
home-manager/services/*/default.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Service configurations should be located in
home-manager/services/<name>/with proper service definitions and correct dependency handling
Files:
home-manager/services/ssh-agent/default.nix
home-manager/services/**/default.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters
Files:
home-manager/services/ssh-agent/default.nix
home-manager/**/*.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
home-manager/**/*.nix: Use typed options whenever possible in Nix configurations
Document all configuration options in Nix modules and programs
Follow home-manager's module structure and keep configurations modular
Use proper indentation and formatting in Nix configuration files
Files:
home-manager/services/ssh-agent/default.nix
home-manager/services/**/*.nix
📄 CodeRabbit inference engine (.cursor/rules/nix.mdc)
Service configurations in
home-manager/services/should follow systemd service conventions, include proper service dependencies, and have clear documentation for service parameters
Files:
home-manager/services/ssh-agent/default.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
- GitHub Check: lua-neovim-test
- GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
- GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
- GitHub Check: e2e-run (MacOS, macos-latest)
- GitHub Check: lua-neovim
- GitHub Check: nix-linux
- GitHub Check: nix-nixos
- GitHub Check: lua-hammerspoon
- GitHub Check: e2e-run (NixOS, ubuntu-latest)
- GitHub Check: shellcheck
- GitHub Check: shellspec
🔇 Additional comments (3)
home-manager/services/ssh-agent/default.nix (3)
1-10: LGTM! Clean module structure.The module structure follows Nix conventions with proper platform detection utilities imported for conditional logic.
11-19: LGTM! Proper platform-specific configuration.The Linux-specific keychain configuration is properly guarded with
lib.mkIf isLinux, andlib.mkAfterensures correct shell initialization ordering. The comments clearly document the difference between Linux and macOS key management approaches.
26-31: LGTM! Proper keychain initialization with appropriate error handling.The keychain initialization logic is well-structured:
- Checks for keys before attempting initialization
- Uses appropriate flags (
--eval,--quiet,--confirm)- Comment clearly documents that
--confirmwill skip passphrase-protected keys in non-interactive contexts- Error handling with
or trueis appropriate for login scripts to prevent shell startup failures
| # Always try to load the default key | ||
| if test -f ~/.ssh/id_ed25519 | ||
| set -a keys ~/.ssh/id_ed25519 | ||
| end |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Search for references to id_ed25519_github in the codebase
rg "id_ed25519_github" -n --type-list | head -5
rg "id_ed25519_github" -n 2>/dev/null || echo "No references found"Repository: shunkakinoki/dotfiles
Length of output: 2153
🏁 Script executed:
# Check for SSH identity configurations that might reference this key pattern
rg "IdentityFile|identity.*github|ssh.*github" -n -g "*.nix" -g "*.conf" -g "*.ssh" 2>/dev/null | head -20Repository: shunkakinoki/dotfiles
Length of output: 941
🏁 Script executed:
# Get full context of the ssh-agent service configuration
if [ -f "home-manager/services/ssh-agent/default.nix" ]; then
wc -l "home-manager/services/ssh-agent/default.nix"
cat -n "home-manager/services/ssh-agent/default.nix"
fiRepository: shunkakinoki/dotfiles
Length of output: 1325
This removal is a breaking change—verify user migration path or update documentation.
The removal of automatic ~/.ssh/id_ed25519_github loading is confirmed to impact multiple parts of the codebase: SSH client configuration (home-manager/programs/ssh/default.nix:41), a dedicated _ssh_add_github Fish function, and host-specific key setup in named-hosts/kyber/.
While an on-demand mechanism exists via the _ssh_add_github function, users who relied on automatic loading will need to manually invoke it or rename their key to the default. Ensure:
- Migration guide or release notes document this behavior change
- Users are directed to the
_ssh_add_githubfunction as the replacement for automatic loading - Consider whether the default key should still support GitHub usage, or if the dedicated function is the intended pattern
There was a problem hiding this comment.
2 issues found across 10 files (changes from recent commits).
Prompt for AI agents (all 2 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="home-manager/services/cliproxyapi/scripts/recover-auth.sh">
<violation number="1" location="home-manager/services/cliproxyapi/scripts/recover-auth.sh:12">
P2: Unquoted variable `$AUTH_DIR` inside command substitution could cause issues with paths containing spaces. All other usages of `$AUTH_DIR` in this script are properly quoted.</violation>
</file>
<file name="home-manager/services/cliproxyapi/scripts/backup-auth.sh">
<violation number="1" location="home-manager/services/cliproxyapi/scripts/backup-auth.sh:12">
P2: Unquoted variable `$AUTH_DIR` in command substitution could cause issues if the path contains spaces or special characters. Quote the variable for safety.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| AUTH_DIR="$CONFIG_DIR/objectstore/auths" | ||
|
|
||
| # Check if auth directory is missing or empty | ||
| if [ ! -d "$AUTH_DIR" ] || [ -z "$(ls -A $AUTH_DIR 2>/dev/null)" ]; then |
There was a problem hiding this comment.
P2: Unquoted variable $AUTH_DIR inside command substitution could cause issues with paths containing spaces. All other usages of $AUTH_DIR in this script are properly quoted.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/cliproxyapi/scripts/recover-auth.sh, line 12:
<comment>Unquoted variable `$AUTH_DIR` inside command substitution could cause issues with paths containing spaces. All other usages of `$AUTH_DIR` in this script are properly quoted.</comment>
<file context>
@@ -0,0 +1,22 @@
+AUTH_DIR="$CONFIG_DIR/objectstore/auths"
+
+# Check if auth directory is missing or empty
+if [ ! -d "$AUTH_DIR" ] || [ -z "$(ls -A $AUTH_DIR 2>/dev/null)" ]; then
+ echo "Auth files missing, attempting recovery from R2 backup..." >&2
+ mkdir -p "$AUTH_DIR"
</file context>
✅ Addressed in 9a5171f
| AUTH_DIR="$CONFIG_DIR/objectstore/auths" | ||
|
|
||
| # Check if auth directory has files | ||
| if [ -d "$AUTH_DIR" ] && [ -n "$(ls -A $AUTH_DIR 2>/dev/null)" ]; then |
There was a problem hiding this comment.
P2: Unquoted variable $AUTH_DIR in command substitution could cause issues if the path contains spaces or special characters. Quote the variable for safety.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/cliproxyapi/scripts/backup-auth.sh, line 12:
<comment>Unquoted variable `$AUTH_DIR` in command substitution could cause issues if the path contains spaces or special characters. Quote the variable for safety.</comment>
<file context>
@@ -0,0 +1,21 @@
+AUTH_DIR="$CONFIG_DIR/objectstore/auths"
+
+# Check if auth directory has files
+if [ -d "$AUTH_DIR" ] && [ -n "$(ls -A $AUTH_DIR 2>/dev/null)" ]; then
+ echo "Backing up auth files to R2 backup directory..." >&2
+ AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
</file context>
✅ Addressed in 9a5171f
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (4)
home-manager/services/default.nix (1)
1-26: Consider adding a module-level documentation comment.While the file structure is clear, a brief header comment explaining that this module aggregates and exports all home-manager service configurations would improve maintainability for future contributors.
📝 Example documentation comment
+# Service module aggregator for home-manager +# Imports and exports all service configurations as a list { config, lib,Based on coding guidelines, documenting configuration modules is recommended.
home-manager/services/cliproxyapi/default.nix (1)
45-59: Consider reducing backup frequency and adding documentation.The 5-minute backup interval (StartInterval = 300) may be unnecessarily aggressive for authentication files that likely change infrequently. Consider increasing the interval to 15-30 minutes unless there's a specific requirement for such frequent backups.
Additionally, document the purpose and behavior of this backup service with comments explaining:
- What files are being backed up
- Why the 5-minute interval was chosen
- The relationship to the main cliproxyapi service
Based on learnings, service configurations should include clear documentation for service parameters.
Suggested documentation improvement
+ # Backup/recovery service for auth files + # Runs every 5 minutes to back up ~/.cli-proxy-api/objectstore/auths to R2 + # and recover missing files if needed (protects against race condition deletions) launchd.agents.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isDarwin {home-manager/services/cliproxyapi/scripts/backup-and-recover.sh (1)
1-25: Add validation for required environment variables.The script sources
.envbut doesn't validate that the requiredOBJECTSTORE_*environment variables are set before proceeding. This could lead to confusing failures in the backup/recovery scripts when AWS commands fail due to missing credentials.Suggested validation
# Source .env for credentials if [ -f "$HOME/dotfiles/.env" ]; then set -a # shellcheck source=/dev/null source "$HOME/dotfiles/.env" set +a fi +# Validate required environment variables +required_vars=("OBJECTSTORE_ENDPOINT" "OBJECTSTORE_BUCKET" "OBJECTSTORE_ACCESS_KEY" "OBJECTSTORE_SECRET_KEY") +for var in "${required_vars[@]}"; do + if [ -z "${!var:-}" ]; then + echo "[$(date)] Warning: $var not set, skipping backup/recovery" >&2 + exit 0 + fi +done + # Run backuphome-manager/services/cliproxyapi/start.sh (1)
21-47: LGTM! Backup/recovery integration is well-structured.The changes successfully integrate backup and recovery functionality into the startup flow:
- Object storage environment variables are properly exported at the top
- Backup runs before config generation to preserve existing state
- Recovery runs after config generation to restore missing files
- Conditional execution with
-xchecks ensures scripts only run when presentThe addition of
__ZAI_API_KEY__substitution aligns with the new Z-AI provider configuration.Optional: Add comment explaining the environment variable fallback logic
+# Export S3-compatible object storage env vars (needed for backup/recovery) +# Fallback order: OBJECTSTORE_* → AWS_S3_* → AWS_* (for compatibility) export OBJECTSTORE_ENDPOINT="${OBJECTSTORE_ENDPOINT:-${AWS_S3_ENDPOINT:-}}" export OBJECTSTORE_BUCKET="${OBJECTSTORE_BUCKET:-${AWS_S3_BUCKET:-}}" export OBJECTSTORE_ACCESS_KEY="${OBJECTSTORE_ACCESS_KEY:-${AWS_ACCESS_KEY_ID:-}}" export OBJECTSTORE_SECRET_KEY="${OBJECTSTORE_SECRET_KEY:-${AWS_SECRET_ACCESS_KEY:-}}"This clarifies the multiple fallback levels for future maintainers.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (9)
config/cliproxyapi/config.yaml(1 hunks)config/opencode/opencode.jsonc(1 hunks)home-manager/default.nix(2 hunks)home-manager/services/cliproxyapi/default.nix(2 hunks)home-manager/services/cliproxyapi/scripts/backup-and-recover.sh(1 hunks)home-manager/services/cliproxyapi/scripts/backup-auth.sh(1 hunks)home-manager/services/cliproxyapi/scripts/recover-auth.sh(1 hunks)home-manager/services/cliproxyapi/start.sh(1 hunks)home-manager/services/default.nix(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- home-manager/default.nix
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{sh,bash}
📄 CodeRabbit inference engine (CLAUDE.md)
Use shfmt with 2-space indentation for shell scripts
**/*.{sh,bash}: Use 2 spaces for indentation in shell scripts
Add proper shebang lines to shell scripts
Follow shellcheck recommendations in shell scripts
Document complex commands in shell scripts
Use consistent variable naming in shell scripts
Files:
home-manager/services/cliproxyapi/scripts/backup-and-recover.shhome-manager/services/cliproxyapi/scripts/backup-auth.shhome-manager/services/cliproxyapi/scripts/recover-auth.shhome-manager/services/cliproxyapi/start.sh
**/*.{json,yaml,yml,toml}
📄 CodeRabbit inference engine (.cursor/rules/formatting.mdc)
**/*.{json,yaml,yml,toml}: Use consistent indentation (2 spaces) in configuration files
Sort keys alphabetically when possible in configuration files
Use clear, descriptive names in configuration files
Files:
config/cliproxyapi/config.yaml
**/*.{yaml,yml,toml}
📄 CodeRabbit inference engine (.cursor/rules/formatting.mdc)
Add comments for complex configurations
Files:
config/cliproxyapi/config.yaml
**/*.nix
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.nix: Use nixfmt for formatting all Nix files
Document complex configurations with comments in Nix files
**/*.nix: Use 2 spaces for indentation in Nix files
Keep line length under 100 characters in Nix files
Sort attribute sets alphabetically in Nix files
Use consistent spacing around operators in Nix files
Format lists and sets consistently in Nix filesUse treefmt.toml for formatting Nix files
**/*.nix: UsemkOptionfor configurable options in Nix modules
Implement proper typing for all options in Nix modules
Follow the Nix expression language style guide
Files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
**/default.nix
📄 CodeRabbit inference engine (CLAUDE.md)
Use
default.nixfiles for module exports
Files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
home-manager/services/*/default.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Service configurations should be located in
home-manager/services/<name>/with proper service definitions and correct dependency handling
Files:
home-manager/services/cliproxyapi/default.nix
home-manager/services/**/default.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters
Files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
home-manager/**/*.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
home-manager/**/*.nix: Use typed options whenever possible in Nix configurations
Document all configuration options in Nix modules and programs
Follow home-manager's module structure and keep configurations modular
Use proper indentation and formatting in Nix configuration files
Files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
home-manager/services/**/*.nix
📄 CodeRabbit inference engine (.cursor/rules/nix.mdc)
Service configurations in
home-manager/services/should follow systemd service conventions, include proper service dependencies, and have clear documentation for service parameters
Files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
**/*.{js,jsx,ts,tsx,json,jsonc,md}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Use Biome for code formatting as configured in biome.json
Files:
config/opencode/opencode.jsonc
🧠 Learnings (15)
📚 Learning: 2025-11-25T09:34:40.062Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-11-25T09:34:40.062Z
Learning: Document all major changes in Nix configurations
Applied to files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
📚 Learning: 2025-11-25T09:35:01.066Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/nix.mdc:0-0
Timestamp: 2025-11-25T09:35:01.066Z
Learning: Applies to home-manager/services/**/*.nix : Service configurations in `home-manager/services/` should follow systemd service conventions, include proper service dependencies, and have clear documentation for service parameters
Applied to files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/services/**/default.nix : Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters
Applied to files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/programs/**/*.nix : Follow program-specific best practices in program configuration files
Applied to files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:40.062Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-11-25T09:34:40.062Z
Learning: Keep configurations modular across home-manager, hosts, and nix-darwin directories
Applied to files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
📚 Learning: 2025-11-25T09:35:01.066Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/nix.mdc:0-0
Timestamp: 2025-11-25T09:35:01.066Z
Learning: Applies to home-manager/programs/**/*.nix : Program configurations in `home-manager/programs/` should be organized by program name, include all necessary dependencies, use `home.packages` for package installations, and use `programs.<name>` when available in home-manager
Applied to files:
home-manager/services/cliproxyapi/default.nixhome-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/services/*/default.nix : Service configurations should be located in `home-manager/services/<name>/` with proper service definitions and correct dependency handling
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/**/*.nix : Follow home-manager's module structure and keep configurations modular
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/**/*.nix : Document all configuration options in Nix modules and programs
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/programs/**/default.nix : Program configurations must include all necessary dependencies in their configuration
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:23.224Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T09:34:23.224Z
Learning: Applies to nix-darwin/**/*.nix : Use Homebrew only for macOS-specific applications
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:35:01.066Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/nix.mdc:0-0
Timestamp: 2025-11-25T09:35:01.066Z
Learning: Applies to home-manager/modules/**/default.nix : Each module in `home-manager/modules/` should have a clear `default.nix` with proper option declarations following the home-manager module structure
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:23.224Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T09:34:23.224Z
Learning: Prefer Nix packages over external package managers
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:34:40.062Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-11-25T09:34:40.062Z
Learning: Applies to flake.nix : Maintain flake.nix as the main Nix configuration with proper structure
Applied to files:
home-manager/services/default.nix
📚 Learning: 2025-11-25T09:35:01.066Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/nix.mdc:0-0
Timestamp: 2025-11-25T09:35:01.066Z
Learning: Applies to home-manager/modules/**/*.nix : Document all custom modules and options
Applied to files:
home-manager/services/default.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
- GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
- GitHub Check: lua-neovim-test
- GitHub Check: lua-neovim
- GitHub Check: nix-linux
- GitHub Check: lua-hammerspoon
- GitHub Check: nix-nixos
- GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
- GitHub Check: nix-darwin
- GitHub Check: e2e-run (NixOS, ubuntu-latest)
- GitHub Check: shellcheck
- GitHub Check: e2e-run (MacOS, macos-latest)
- GitHub Check: shellspec
🔇 Additional comments (6)
home-manager/services/default.nix (3)
1-6: LGTM! Parameter additions support the refactored ssh-agent module.The addition of
configandlibparameters is necessary to support the updated ssh-agent module import, which now requires these dependencies for its refactored implementation.
14-16: LGTM! Directory-based import follows module structure best practices.The refactored sshAgent import correctly transitions from a file-based to a directory-based module structure (using
default.nix), and properly passes the requiredconfig,lib, andpkgsdependencies to support the updated SSH agent implementation.Based on coding guidelines, this change aligns with the requirement to use
default.nixfiles for module exports and follow home-manager's modular structure.
8-8: Good refactoring to consolidate the brewUpgrader binding.Moving the brewUpgrader import to the top of the let block improves code clarity by consolidating it into a single, clearly visible location.
config/opencode/opencode.jsonc (1)
191-205: LGTM! Z-AI provider integration looks correct.The addition of the z-ai provider with environment variable-based API key configuration aligns with the existing pattern used for openrouter. The structure is consistent with the corresponding changes in
config/cliproxyapi/config.yaml.config/cliproxyapi/config.yaml (1)
80-85: LGTM! Z-AI provider configuration is consistent.The new z-ai provider entry follows the same structure and placeholder pattern as the existing openrouter provider. The configuration aligns with the corresponding changes in
config/opencode/opencode.jsonc.home-manager/services/cliproxyapi/scripts/backup-auth.sh (1)
13-20: Verify aws CLI availability.Same concern as in
recover-auth.sh: the script assumesawsCLI is available without verification. Consider adding a check or ensuringawsis in the service's PATH via the systemd/launchd service definition.Refer to the verification script provided for
recover-auth.shto check aws CLI availability.
| systemd.user.timers.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux { | ||
| Unit = { | ||
| Description = "CLIProxyAPI auth backup and recovery timer"; | ||
| }; | ||
| Timer = { | ||
| OnBootSec = "1min"; | ||
| OnUnitActiveSec = "5min"; | ||
| Unit = "cliproxyapi-backup.service"; | ||
| }; | ||
| Install = { | ||
| WantedBy = [ "timers.target" ]; | ||
| }; | ||
| }; | ||
|
|
||
| systemd.user.services.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux { | ||
| Unit = { | ||
| Description = "CLIProxyAPI auth backup and recovery"; | ||
| }; | ||
| Service = { | ||
| Type = "oneshot"; | ||
| ExecStart = "${pkgs.bash}/bin/bash ${./scripts/backup-and-recover.sh}"; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Add service dependencies to prevent coordination issues.
The backup service and timer lack explicit dependencies on the main cliproxyapi.service. This could lead to:
- Both services accessing the same auth files simultaneously during startup
- Race conditions if backup runs while the main service is modifying files
- Unclear startup ordering
Based on learnings, service configurations should include proper service dependencies.
Recommended fix to add proper service ordering
systemd.user.services.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux {
Unit = {
Description = "CLIProxyAPI auth backup and recovery";
+ After = [ "cliproxyapi.service" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash ${./scripts/backup-and-recover.sh}";
};
};This ensures the backup service runs after the main service is active, reducing the risk of file access conflicts.
📝 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.
| systemd.user.timers.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux { | |
| Unit = { | |
| Description = "CLIProxyAPI auth backup and recovery timer"; | |
| }; | |
| Timer = { | |
| OnBootSec = "1min"; | |
| OnUnitActiveSec = "5min"; | |
| Unit = "cliproxyapi-backup.service"; | |
| }; | |
| Install = { | |
| WantedBy = [ "timers.target" ]; | |
| }; | |
| }; | |
| systemd.user.services.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux { | |
| Unit = { | |
| Description = "CLIProxyAPI auth backup and recovery"; | |
| }; | |
| Service = { | |
| Type = "oneshot"; | |
| ExecStart = "${pkgs.bash}/bin/bash ${./scripts/backup-and-recover.sh}"; | |
| }; | |
| }; | |
| systemd.user.timers.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux { | |
| Unit = { | |
| Description = "CLIProxyAPI auth backup and recovery timer"; | |
| }; | |
| Timer = { | |
| OnBootSec = "1min"; | |
| OnUnitActiveSec = "5min"; | |
| Unit = "cliproxyapi-backup.service"; | |
| }; | |
| Install = { | |
| WantedBy = [ "timers.target" ]; | |
| }; | |
| }; | |
| systemd.user.services.cliproxyapi-backup = lib.mkIf pkgs.stdenv.isLinux { | |
| Unit = { | |
| Description = "CLIProxyAPI auth backup and recovery"; | |
| After = [ "cliproxyapi.service" ]; | |
| }; | |
| Service = { | |
| Type = "oneshot"; | |
| ExecStart = "${pkgs.bash}/bin/bash ${./scripts/backup-and-recover.sh}"; | |
| }; | |
| }; |
| echo "Auth files missing, attempting recovery from R2 backup..." >&2 | ||
| mkdir -p "$AUTH_DIR" | ||
| 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 "✅ Recovered auth files from backup" >&2 || echo "⚠️ Recovery failed (no backup available?)" >&2 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find . -name "recover-auth.sh" -type fRepository: shunkakinoki/dotfiles
Length of output: 124
🏁 Script executed:
cat -n ./home-manager/services/cliproxyapi/scripts/recover-auth.shRepository: shunkakinoki/dotfiles
Length of output: 1050
Verify aws CLI availability before use.
The script uses the aws command on line 17 without checking if it exists in PATH. If aws is not available, the error gets suppressed by 2>/dev/null, leaving only a vague "Recovery failed (no backup available?)" message instead of indicating the actual cause. Add a check like command -v aws >/dev/null 2>&1 || { echo "aws CLI not found" >&2; exit 1; } before the sync command.
🤖 Prompt for AI Agents
In home-manager/services/cliproxyapi/scripts/recover-auth.sh around lines 13 to
21, the script calls the aws CLI without verifying it exists and then silences
errors, which hides the real cause when recovery fails; add a pre-check using
command -v aws >/dev/null 2>&1 and if it fails print "aws CLI not found" to
stderr and exit non-zero before attempting the aws s3 sync, so the script fails
fast with a clear message instead of a vague recovery-failed line.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
config/claude/pushover.sh (1)
27-31: Remove redundant empty check.Lines 29-31 are now unnecessary because line 28's fallback chain (
|| echo "unknown") guarantees a non-empty value. The empty check can never trigger.🔎 Proposed simplification
# Get Computer Name for notifications (macOS friendly name, fallback to hostname) HOSTNAME=$(scutil --get ComputerName 2>/dev/null || hostname -s 2>/dev/null || echo "unknown") -if [ -z "$HOSTNAME" ]; then - HOSTNAME="unknown" -fiAdditionally, consider documenting the macOS-specific behavior inline:
-# Get Computer Name for notifications (macOS friendly name, fallback to hostname) +# Get Computer Name for notifications +# 1. Try macOS-friendly name (scutil - macOS only) +# 2. Fall back to short hostname (portable) +# 3. Default to "unknown" if both fail HOSTNAME=$(scutil --get ComputerName 2>/dev/null || hostname -s 2>/dev/null || echo "unknown")
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
config/claude/pushover.sh(1 hunks)home-manager/services/cliproxyapi/scripts/backup-auth.sh(1 hunks)home-manager/services/cliproxyapi/scripts/recover-auth.sh(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{sh,bash}
📄 CodeRabbit inference engine (CLAUDE.md)
Use shfmt with 2-space indentation for shell scripts
**/*.{sh,bash}: Use 2 spaces for indentation in shell scripts
Add proper shebang lines to shell scripts
Follow shellcheck recommendations in shell scripts
Document complex commands in shell scripts
Use consistent variable naming in shell scripts
Files:
home-manager/services/cliproxyapi/scripts/backup-auth.shconfig/claude/pushover.shhome-manager/services/cliproxyapi/scripts/recover-auth.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: shellcheck
- GitHub Check: nix-linux
- GitHub Check: nix-flake
- GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
- GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
- GitHub Check: lua-neovim-test
- GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
- GitHub Check: e2e-run (NixOS, ubuntu-latest)
🔇 Additional comments (6)
home-manager/services/cliproxyapi/scripts/recover-auth.sh (3)
1-5: Good script setup following best practices.The script properly uses
#!/usr/bin/env bash, includes descriptive comments explaining the purpose, and enables strict error handling withset -euo pipefail. This follows the coding guidelines for shell scripts.
7-9: Clear and consistent variable declarations.The variable names are descriptive and follow consistent naming conventions. Proper quoting is used throughout.
12-12: Variable quoting issue has been resolved.The
$AUTH_DIRvariable in thels -Acommand is now properly quoted, addressing the concern raised in previous reviews.home-manager/services/cliproxyapi/scripts/backup-auth.sh (3)
1-5: Good script setup following best practices.Consistent with
recover-auth.sh, this script properly uses#!/usr/bin/env bash, includes descriptive comments, and enables strict error handling withset -euo pipefail.
7-9: Clear variable declarations.Variable declarations are consistent with the recovery script and properly quoted.
12-12: Variable quoting issue has been resolved.The
$AUTH_DIRvariable in thels -Acommand is now properly quoted, consistent with the fix inrecover-auth.sh.
… and recovery scripts
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
spec/code_syncer_spec.sh (2)
44-54: Consider verifying actual extension filtering behavior.The tests now only check for string presence (
--list-extensions,clean_extension_list) rather than validating that extension filtering works correctly. While this reduces mocking complexity, it also means bugs in the actual filtering logic won't be caught.Consider adding at least one integration test that verifies the extension filtering produces expected output, even if it requires minimal mocking.
73-91: Consider adding behavior verification for config syncing.Similar to the extension filtering tests, these now only verify that certain strings and function names exist in the script. This approach won't catch bugs in the actual config file syncing logic, such as incorrect paths, missing error handling, or failed copy operations.
A middle ground could be a lightweight integration test that creates a minimal fixture and verifies sync_config_file actually copies a file, without the extensive platform-specific mocking from before.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
spec/code_syncer_spec.sh(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{sh,bash}
📄 CodeRabbit inference engine (CLAUDE.md)
Use shfmt with 2-space indentation for shell scripts
**/*.{sh,bash}: Use 2 spaces for indentation in shell scripts
Add proper shebang lines to shell scripts
Follow shellcheck recommendations in shell scripts
Document complex commands in shell scripts
Use consistent variable naming in shell scripts
Files:
spec/code_syncer_spec.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: nix-linux
- GitHub Check: nix-nixos
- GitHub Check: nix-flake
- GitHub Check: nix-darwin
- GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
- GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
- GitHub Check: lua-hammerspoon
- GitHub Check: lua-neovim-test
- GitHub Check: lua-neovim
- GitHub Check: cubic · AI code reviewer
- GitHub Check: shellspec
- GitHub Check: shellcheck
- GitHub Check: e2e-run (MacOS, macos-latest)
- GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
- GitHub Check: e2e-run (NixOS, ubuntu-latest)
🔇 Additional comments (4)
spec/code_syncer_spec.sh (4)
10-11: LGTM: Clean approach to simulate missing CLI.Creating an empty bin directory for PATH restriction is an elegant way to test the "CLI not found" scenario without complex mocking.
29-29: LGTM: Proper cleanup of test artifacts.Correctly removes both temporary directories created during setup.
36-37: LGTM: Effective use of restricted PATH.The restricted PATH approach successfully simulates a missing VS Code CLI while preserving essential shell commands for the test execution.
93-103: LGTM: Adds fswatch integration coverage.The new fswatch tests verify the presence of fswatch checks and fallback messaging. While these are also lightweight string-based checks consistent with the refactored test approach, they do add coverage for a new integration point.
Add configuration for keychain integration on Linux while removing the previous implementation that loaded additional keys. This simplifies the key loading process.
Summary by cubic
Simplified Linux SSH agent keychain by loading only the default key. Added CLIProxyAPI auth backup/recovery and Z.ai provider support.
New Features
Migration
Written for commit f984462. Summary will update automatically on new commits.