From b0a36986a63bb65b6b8da9ada80377205feb3fc2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:51:05 +0000 Subject: [PATCH 1/6] Initial plan From 772f7ffe5df3e8f0f739a90dc1e760ab936f3f54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:53:29 +0000 Subject: [PATCH 2/6] fix: Generate package-lock.json if not present in claude-code tarball Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com> --- nix/claude-code/update.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nix/claude-code/update.sh b/nix/claude-code/update.sh index cfc648bc..76352855 100755 --- a/nix/claude-code/update.sh +++ b/nix/claude-code/update.sh @@ -28,12 +28,17 @@ mkdir -p "$TMPDIR/src" tar -xzf "$TMPDIR/claude-code.tgz" -C "$TMPDIR/src" --strip-components=1 SRC_HASH=$(nix hash path "$TMPDIR/src") -# Get package-lock.json from tarball +# Get package-lock.json from tarball, or generate it if not present if [[ -f "$TMPDIR/src/package-lock.json" ]]; then cp "$TMPDIR/src/package-lock.json" package-lock.json else - echo "Error: No package-lock.json in tarball" - exit 1 + echo "No package-lock.json in tarball, generating from package.json" + # Generate package-lock.json from package.json + cp "$TMPDIR/src/package.json" "$TMPDIR/package.json" + cd "$TMPDIR" + npm install --package-lock-only --ignore-scripts + cd "$SCRIPT_DIR" + cp "$TMPDIR/package-lock.json" package-lock.json fi # Compute npmDepsHash using prefetch-npm-deps From bffc386238dab07302334a08a5fadcbadc94c419 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:54:41 +0000 Subject: [PATCH 3/6] fix: Add robust error handling for package-lock.json generation Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com> --- nix/claude-code/update.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/nix/claude-code/update.sh b/nix/claude-code/update.sh index 76352855..5a61445d 100755 --- a/nix/claude-code/update.sh +++ b/nix/claude-code/update.sh @@ -33,11 +33,22 @@ if [[ -f "$TMPDIR/src/package-lock.json" ]]; then cp "$TMPDIR/src/package-lock.json" package-lock.json else echo "No package-lock.json in tarball, generating from package.json" + # Verify package.json exists + if [[ ! -f "$TMPDIR/src/package.json" ]]; then + echo "Error: No package.json in tarball" + exit 1 + fi # Generate package-lock.json from package.json cp "$TMPDIR/src/package.json" "$TMPDIR/package.json" - cd "$TMPDIR" - npm install --package-lock-only --ignore-scripts - cd "$SCRIPT_DIR" + (cd "$TMPDIR" && npm install --package-lock-only --ignore-scripts) || { + echo "Error: Failed to generate package-lock.json" + exit 1 + } + # Verify package-lock.json was generated + if [[ ! -f "$TMPDIR/package-lock.json" ]]; then + echo "Error: package-lock.json was not generated" + exit 1 + fi cp "$TMPDIR/package-lock.json" package-lock.json fi From 84dd3b7081656a89a4294be1ae24a54d9956cf7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 13:02:22 +0000 Subject: [PATCH 4/6] feat: Run update-claude-code workflow on PR changes to verify build Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com> --- .github/workflows/update-claude-code.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/update-claude-code.yml b/.github/workflows/update-claude-code.yml index 99dbbf2c..ffa246da 100644 --- a/.github/workflows/update-claude-code.yml +++ b/.github/workflows/update-claude-code.yml @@ -5,6 +5,10 @@ on: # Run daily at 6 AM UTC - cron: '0 6 * * *' workflow_dispatch: # Allow manual trigger + pull_request: + paths: + - 'nix/claude-code/**' + - '.github/workflows/update-claude-code.yml' jobs: update: @@ -25,6 +29,7 @@ jobs: experimental-features = nix-command flakes - name: Update claude-code package + if: github.event_name != 'pull_request' id: update run: | # Script exits 0 if already at latest (no changes to commit) @@ -35,12 +40,14 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Update flake.lock + if: github.event_name != 'pull_request' run: nix flake update - name: Verify build run: nix develop --command claude --version - name: Create Pull Request + if: github.event_name != 'pull_request' uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} From d12b23dcb0d1d3383bd0b12faa28124e167ded2a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 21:41:16 +0000 Subject: [PATCH 5/6] fix: Run update script on PRs to test changes Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com> --- .github/workflows/update-claude-code.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-claude-code.yml b/.github/workflows/update-claude-code.yml index ffa246da..cbebea43 100644 --- a/.github/workflows/update-claude-code.yml +++ b/.github/workflows/update-claude-code.yml @@ -28,7 +28,14 @@ jobs: extra_nix_config: | experimental-features = nix-command flakes - - name: Update claude-code package + - name: Update claude-code package (test) + if: github.event_name == 'pull_request' + run: | + # On PRs, run the update script to test it works + # but don't commit or create PRs with the changes + ./nix/claude-code/update.sh || echo "::warning::Update script execution test failed" + + - name: Update claude-code package (production) if: github.event_name != 'pull_request' id: update run: | From a5051c3cab4c463232723440aeb86e57976b05ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:44:36 +0000 Subject: [PATCH 6/6] fix: Apply review comments - preserve .npmrc and fail on test errors Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com> --- .github/workflows/update-claude-code.yml | 8 +++++++- nix/claude-code/update.sh | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-claude-code.yml b/.github/workflows/update-claude-code.yml index cbebea43..92d6b0fa 100644 --- a/.github/workflows/update-claude-code.yml +++ b/.github/workflows/update-claude-code.yml @@ -33,7 +33,13 @@ jobs: run: | # On PRs, run the update script to test it works # but don't commit or create PRs with the changes - ./nix/claude-code/update.sh || echo "::warning::Update script execution test failed" + set +e + ./nix/claude-code/update.sh + status=$? + if [ "$status" -ne 0 ]; then + echo "::warning::Update script execution test failed (exit code: $status)" + exit "$status" + fi - name: Update claude-code package (production) if: github.event_name != 'pull_request' diff --git a/nix/claude-code/update.sh b/nix/claude-code/update.sh index 5a61445d..0dc7ddf8 100755 --- a/nix/claude-code/update.sh +++ b/nix/claude-code/update.sh @@ -40,6 +40,10 @@ else fi # Generate package-lock.json from package.json cp "$TMPDIR/src/package.json" "$TMPDIR/package.json" + # Preserve any npm configuration from the tarball when generating the lockfile + if [[ -f "$TMPDIR/src/.npmrc" ]]; then + cp "$TMPDIR/src/.npmrc" "$TMPDIR/.npmrc" + fi (cd "$TMPDIR" && npm install --package-lock-only --ignore-scripts) || { echo "Error: Failed to generate package-lock.json" exit 1