Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions home-manager/modules/npm-globals/install-npm-globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@ if [ -n "$DEPS" ]; then
bun install --global $DEPS 2>/dev/null || true
fi

# Apply dependency overrides to the global install
# Bun's flat hoisting can resolve incompatible versions (e.g. pino@10 vs pino-http@10.5)
OVERRIDES=$(jq -c '.overrides // empty' "$PACKAGE_JSON" 2>/dev/null || true)
if [ -n "$OVERRIDES" ]; then
GLOBAL_PKG="${HOME}/.bun/install/global/package.json"
if [ -f "$GLOBAL_PKG" ]; then
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&

@cubic-dev-ai cubic-dev-ai Bot Apr 5, 2026 •

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.

P2: The new jq expression overwrites existing global overrides instead of merging, which can silently drop previously configured override rules.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/modules/npm-globals/install-npm-globals.sh, line 58:

<comment>The new jq expression overwrites existing global `overrides` instead of merging, which can silently drop previously configured override rules.</comment>

<file context>
@@ -49,4 +49,17 @@ if [ -n "$DEPS" ]; then
+if [ -n "$OVERRIDES" ]; then
+  GLOBAL_PKG="${HOME}/.bun/install/global/package.json"
+  if [ -f "$GLOBAL_PKG" ]; then
+    jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
+      mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
+    (cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
</file context>
Suggested change
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
jq --argjson overrides "$OVERRIDES" '.overrides = ((.overrides // {}) + $overrides)' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
Fix with Cubic

mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
Comment on lines +58 to +59

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 jq and mv commands should handle failures gracefully to remain consistent with the error handling pattern used elsewhere in this script. This ensures that a failure in patching the global package.json (due to permissions or an invalid global manifest) does not halt the entire home-manager activation process.

Suggested change
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG" || true
References
  1. Maintain consistency with established patterns for writing scripts that are extracted from Nix expressions.

Comment on lines +58 to +59

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description says the dotfiles overrides are merged into the global package.json, but this jq filter replaces the entire .overrides object. If the global file already has overrides (or Bun adds some in the future), they will be lost. Consider merging instead of overwriting (e.g., combine existing .overrides with the new overrides).

Copilot uses AI. Check for mistakes.
(cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
echo "Applied dependency overrides to global install"
Comment on lines +58 to +61

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

This block runs under set -e, but the jq ... > tmp && mv ... pipeline isn't protected by || true / error handling. If jq fails (e.g., corrupted global package.json), the whole activation will abort, unlike the earlier best-effort bun install --global ... || true. Consider making the override-application step best-effort as well (or emit an explicit error and continue).

Suggested change
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
(cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
echo "Applied dependency overrides to global install"
GLOBAL_PKG_TMP="${GLOBAL_PKG}.tmp"
if jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"$GLOBAL_PKG_TMP" &&
mv "$GLOBAL_PKG_TMP" "$GLOBAL_PKG"; then
(cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
echo "Applied dependency overrides to global install"
else
rm -f "$GLOBAL_PKG_TMP"
echo "Warning: failed to apply dependency overrides to global install, continuing"
fi

Copilot uses AI. Check for mistakes.
fi
fi

echo "npm globals installation complete"
2 changes: 1 addition & 1 deletion home-manager/modules/paperclip/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lib.mkIf host.isKyber {
};
Service = {
Type = "simple";
ExecStart = "${homeDir}/dotfiles/node_modules/.bin/paperclipai run --no-repair";
ExecStart = "${homeDir}/.bun/bin/paperclipai run --no-repair";

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

Wrapping the ExecStart path in double quotes is a best practice for systemd units to ensure the command is correctly parsed if the path contains spaces, even if unlikely in this specific environment.

      ExecStart = "\"${homeDir}/.bun/bin/paperclipai\" run --no-repair";

Restart = "always";
RestartSec = "5s";
Environment = [
Expand Down
Loading