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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# AI
.claude
.devenv.nix
objectstore

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 objectstore directory appears to be created within $HOME/.cli-proxy-api, which is typically outside the scope of this Git repository. Consequently, this .gitignore entry may not have any effect. If this entry is intended for a local development workflow where an objectstore directory is created at the repository root, consider adding a comment to clarify its purpose. Otherwise, it could be removed to avoid confusion.


# Nix
.devenv
Expand Down
12 changes: 9 additions & 3 deletions home-manager/services/cliproxyapi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ in
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"${./start.sh}"
"${./scripts/start.sh}"
];
Environment = {
PATH = "${lib.makeBinPath [ pkgs.gnused ]}:/opt/homebrew/bin:/usr/local/bin";
HOME = "/Users/shunkakinoki";

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.

critical

Hardcoding the HOME environment variable to a specific user's path (/Users/shunkakinoki) makes this configuration non-portable and will cause it to fail for any other user or on a different machine. You should use a variable to dynamically set the correct home directory. In a home-manager module, config.home.homeDirectory is the standard way to reference the user's home directory.

        HOME = config.home.homeDirectory;

Copilot AI Dec 25, 2025

Copy link

Choose a reason for hiding this comment

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

The HOME environment variable is hardcoded to a specific user path '/Users/shunkakinoki'. This makes the service configuration non-portable and will fail for any other user or system. Consider using a variable or configuration option that can be set per-user or per-deployment, or remove this if it's not strictly necessary.

Suggested change
HOME = "/Users/shunkakinoki";

Copilot uses AI. Check for mistakes.
PATH = "${
lib.makeBinPath [
pkgs.gnused
pkgs.coreutils
]
}:/opt/homebrew/bin:/usr/local/bin:/usr/bin";
};
KeepAlive = true;
RunAtLoad = true;
Expand All @@ -34,7 +40,7 @@ in
pkgs.bash
]
}";
ExecStart = "${pkgs.bash}/bin/bash ${./start.sh}";
ExecStart = "${pkgs.bash}/bin/bash ${./scripts/start.sh}";

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 start.sh script uses mkdir and cp, which are provided by coreutils. The PATH for this systemd service doesn't include coreutils, which will likely cause the script to fail on Linux systems. For consistency with the launchd configuration and to ensure the script runs correctly, you should add pkgs.coreutils to the lib.makeBinPath list in the Environment setting for this service.

Restart = "always";
RestartSec = 3;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,16 @@ 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:-}}"

# Backup auth files to R2 before starting service
# This protects against race condition deletions
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -x "$SCRIPT_DIR/scripts/backup-auth.sh" ]; then
bash "$SCRIPT_DIR/scripts/backup-auth.sh"
fi

# Generate config from template with secrets injected
if [ -f "$TEMPLATE" ]; then
sed \
-e "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" \
-e "s|__CLIPROXY_MANAGEMENT_PASSWORD__|${CLIPROXY_MANAGEMENT_PASSWORD:-}|g" \
-e "s|__ZAI_API_KEY__|${ZAI_API_KEY:-}|g" \
"$TEMPLATE" >"$CONFIG"
fi

# Recover auth files from backup if they're missing
# This handles race condition where files get deleted during config reload
if [ -x "$SCRIPT_DIR/scripts/recover-auth.sh" ]; then
bash "$SCRIPT_DIR/scripts/recover-auth.sh"
# Also copy to objectstore config location (cliproxyapi uses this for persistence)
mkdir -p "$CONFIG_DIR/objectstore/config"
cp "$CONFIG" "$CONFIG_DIR/objectstore/config/config.yaml"
Comment on lines +34 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ensure coreutils are in PATH for Linux service

On Linux, systemd.user.services.cliproxyapi sets PATH to only gnused and bash in home-manager/services/cliproxyapi/default.nix, so the new mkdir/cp calls added here will fail with command not found (and set -e will abort startup) unless the template is missing. This regression only affects the systemd service because launchd’s PATH was updated to include coreutils, but the Linux PATH was not, so the service can’t create/copy the objectstore config.

Useful? React with 👍 / 👎.

fi

# Change to config dir so logs are created there
Expand Down
Loading