Skip to content

refactor: move ICU env vars from build script to nix shell config - #1325

Merged
shunkakinoki merged 1 commit into
mainfrom
refactor/icu-env-via-nix
Apr 1, 2026
Merged

refactor: move ICU env vars from build script to nix shell config#1325
shunkakinoki merged 1 commit into
mainfrom
refactor/icu-env-via-nix

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add PKG_CONFIG_PATH, CGO_CFLAGS, CGO_LDFLAGS for icu.dev to fish/bash/zsh shell init (Linux block) — same pattern as existing openssl.dev setup
  • Add same env vars to make-updater systemd service Environment
  • Remove inline nix-build ICU logic from update-local-binaries.sh
  • Include build robustness fixes from fix: improve local binary build robustness #1324 (Makefile fallthrough, mise trust, submodule init)

Test plan

  • make build succeeds
  • make shell-test passes (no new failures)
  • make format clean (0 changed)

🤖 Generated with Claude Code


Summary by cubic

Move ICU CGo env vars from the build script into Nix shell init and the make-updater service to standardize builds. Removes inline nix-build and makes Go/CGo builds more reliable.

  • Refactors
    • Set ICU PKG_CONFIG_PATH, CGO_CFLAGS, CGO_LDFLAGS in Bash/Zsh/Fish (Linux), matching the existing OpenSSL setup.
    • Add the same env vars to the make-updater systemd unit Environment.
    • Remove ICU nix-build logic from update-local-binaries.sh.
    • Run mise trust before mise install.
    • Initialize git submodules when .gitmodules is present.
    • Fall through when no make build target and try Cargo/Go build paths.

Written for commit 42f8043. Summary will update on new commits.

Instead of running nix-build inline during each Go build, set
PKG_CONFIG_PATH, CGO_CFLAGS, and CGO_LDFLAGS for icu.dev in
fish/bash/zsh shell init and the make-updater systemd service.

Also includes build robustness fixes:
- Fall through to Cargo.toml when Makefile has no build target
- Auto-trust mise.toml before installing tools
- Init git submodules before building if .gitmodules exists
Copilot AI review requested due to automatic review settings April 1, 2026 13:22
@shunkakinoki
shunkakinoki merged commit 9f8d6cb into main Apr 1, 2026
27 of 28 checks passed
@shunkakinoki
shunkakinoki deleted the refactor/icu-env-via-nix branch April 1, 2026 13:22
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46b67312-7328-4ed9-b86a-58fe6ae04e84

📥 Commits

Reviewing files that changed from the base of the PR and between 5ea3ff9 and 42f8043.

📒 Files selected for processing (5)
  • home-manager/programs/bash/default.nix
  • home-manager/programs/fish/default.nix
  • home-manager/programs/zsh/default.nix
  • home-manager/services/make-updater/default.nix
  • scripts/update-local-binaries.sh

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Added ICU library support across shell environments for CGo-based builds
    • Integrated git submodule initialization in build scripts
  • Improvements

    • Enhanced Makefile build target detection
    • Added mise trust verification step before dependency installation
    • Improved service environment configuration for build tools

Walkthrough

The PR adds ICU (International Components for Unicode) library support for CGo-based builds across multiple shell configurations (bash, fish, zsh) and a systemd service by configuring pkg-config paths and compiler/linker flags. It also enhances the build script with mise trust verification, git submodule initialization, and improved Makefile build-target detection.

Changes

Cohort / File(s) Summary
Shell Environment Configuration
home-manager/programs/bash/default.nix, home-manager/programs/fish/default.nix, home-manager/programs/zsh/default.nix
Added ICU-related environment variables (PKG_CONFIG_PATH, CGO_CFLAGS, CGO_LDFLAGS) across all three shell configurations to support CGo builds with ICU library dependencies.
Systemd Service Environment
home-manager/services/make-updater/default.nix
Extended the make-updater systemd user service environment to include ICU and OpenSSL pkg-config paths, compiler flags, and linker flags for CGo-based builds.
Build Script Enhancements
scripts/update-local-binaries.sh
Added mise trust step, git submodule initialization, reworked Makefile build-target detection (now checks existence before execution), and added comment documenting external ICU/CGo environment variable supply.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 Hoppy hops through ICU lands,
Building bridges with gentle hands,
CGo flags and pkg-config bright,
Unicode dreams take global flight! 🌍

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/icu-env-via-nix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 1, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Refactor: move ICU environment variables from build script to Nix shell configuration.

What changed?

  • Added PKG_CONFIG_PATH, CGO_CFLAGS, CGO_LDFLAGS for icu.dev to fish/bash/zsh shell init (Linux block), mirroring the existing openssl.dev setup.
  • Added same environment variables to make-updater systemd service Environment.
  • Removed inline nix-build ICU logic from update-local-binaries.sh.
  • Included build robustness fixes from fix: improve local binary build robustness #1324 (Makefile fallthrough, mise trust, submodule init).

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 5 files

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Performed full review of 5ea3ff9...42f8043

Analysis

• Darwin launchd service is missing ICU environment variables (PKG_CONFIG_PATH, CGO_CFLAGS, CGO_LDFLAGS) that were added to the Linux systemd service. This creates a critical platform inconsistency where automated updates via macOS launchd will fail to build Go projects with ICU dependencies, while interactive shells work fine.

• Development shell (devenv.nix) lacks ICU environment variables present in production shell configs, creating an inconsistency where developers may not catch build failures that only manifest in automated environments.

• The refactoring delegates platform-specific package path resolution to Nix configs (good), but incomplete application across all execution contexts (launchd, devenv) undermines the architectural goal of centralized, consistent configuration management.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

0 files reviewed | 0 comments | Edit Agent SettingsRead Docs

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request adds ICU and CGo environment variables to shell configurations and the make-updater service to support CGo-based builds. Additionally, the update-local-binaries script is updated to trust mise configurations, initialize git submodules, and handle Makefile build targets more flexibly by falling back to other build systems when necessary. I have no feedback to provide.

Copilot AI left a comment

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.

Pull request overview

Refactors ICU-related environment setup by moving ICU CGo/pkg-config flags out of the build script and into nix shell/service configuration, while also improving build robustness for repos using mise, git submodules, and varying Makefile targets.

Changes:

  • Add ICU PKG_CONFIG_PATH, CGO_CFLAGS, and CGO_LDFLAGS to fish/bash/zsh shell init (Linux) and to the make-updater systemd service.
  • Remove/avoid implicit ICU build logic in update-local-binaries.sh, and improve Makefile target fallthrough behavior.
  • Add robustness steps: mise trust and git submodule init.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/update-local-binaries.sh Adds mise trust + submodule init and adjusts Makefile build/fallthrough logic; notes ICU env vars come from shell init.
home-manager/services/make-updater/default.nix Sets ICU/OpenSSL-related PKG_CONFIG_PATH and CGo flags for the systemd service environment.
home-manager/programs/zsh/default.nix Exports ICU CGo/pkg-config env vars for Linux shells.
home-manager/programs/fish/default.nix Exports ICU CGo/pkg-config env vars for Linux fish shells.
home-manager/programs/bash/default.nix Exports ICU CGo/pkg-config env vars for Linux bash shells (in both relevant init blocks).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Install tools via mise if mise.toml is present
if [ -f "$build_dir/mise.toml" ] && command -v mise >/dev/null 2>&1; then
log_step " Installing tools via mise..."
(cd "$build_dir" && mise trust 2>&1) || true

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

mise trust persists a trust decision for the directory (and potentially its tool config) into the user’s mise trust store. Running it automatically inside an update/build script can unintentionally trust configs from repos the user didn’t explicitly approve. Prefer avoiding persistent trust changes from automation (e.g., require an explicit opt-in flag/env var before running mise trust, or use a scoped/non-persistent mechanism if mise supports it), so the script can build without mutating global trust state.

Suggested change
(cd "$build_dir" && mise trust 2>&1) || true
if [ "${MISE_AUTO_TRUST:-}" = "1" ]; then
(cd "$build_dir" && mise trust 2>&1) || true
else
log_warn " Skipping 'mise trust' because MISE_AUTO_TRUST is not set to 1; run 'mise trust' manually if needed."
fi

Copilot uses AI. Check for mistakes.
Comment on lines +146 to +149
# Initialize git submodules if .gitmodules exists
if [ -f "$repo_dir/.gitmodules" ]; then
log_step " Initializing submodules..."
(cd "$repo_dir" && git submodule update --init --recursive 2>&1) || true

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

Submodule initialization is performed in repo_dir, but builds are executed from build_dir throughout this function. If build_dir is a separate checkout/copy (as the surrounding code implies), submodules in the build tree won’t be initialized and builds can fail. Initialize submodules in the same directory you build from (and check .gitmodules in that directory) to keep the operation consistent and effective.

Suggested change
# Initialize git submodules if .gitmodules exists
if [ -f "$repo_dir/.gitmodules" ]; then
log_step " Initializing submodules..."
(cd "$repo_dir" && git submodule update --init --recursive 2>&1) || true
# Initialize git submodules if .gitmodules exists in the build directory
if [ -f "$build_dir/.gitmodules" ]; then
log_step " Initializing submodules..."
(cd "$build_dir" && git submodule update --init --recursive 2>&1) || true

Copilot uses AI. Check for mistakes.
Comment on lines +162 to 171
# If Makefile has no build target, fall through to other build systems
if (cd "$build_dir" && $make_cmd -n build >/dev/null 2>&1); then
if (cd "$build_dir" && $make_cmd build 2>&1); then
return 0
else
return 1
fi
else
return 1
log_warn " Makefile has no build target, trying other build systems..."
fi

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

Using make -n build as a proxy for 'target exists' can misclassify real Makefile errors (e.g., missing included files, syntax errors, required env) as 'no build target', causing the script to silently fall through to other build systems and hide the actual failure. A more reliable approach is to only fall through when the failure is specifically 'No rule to make target …', and otherwise treat it as a genuine Makefile error (return non-zero and surface the output).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants