Skip to content

Fix the non-nix-build on macOS#523

Merged
zah merged 36 commits intomainfrom
nix-mac-compatibility
Feb 3, 2026
Merged

Fix the non-nix-build on macOS#523
zah merged 36 commits intomainfrom
nix-mac-compatibility

Conversation

@zah
Copy link
Member

@zah zah commented Jan 30, 2026

No description provided.

@zah zah force-pushed the nix-mac-compatibility branch from 78f8d29 to d8962cd Compare January 30, 2026 10:15
@metacraft-labs metacraft-labs deleted a comment from github-actions bot Jan 30, 2026
@zah zah force-pushed the nix-mac-compatibility branch 2 times, most recently from 22be98a to ee69eb5 Compare January 30, 2026 10:50
zah and others added 18 commits February 1, 2026 06:51
When Nix builds with .?submodules=1, using self.outPath ensures
that git submodules (like tree-sitter-nim) are included in the
source copied to the build sandbox.

Previously, src = ../../. only included files from the main repo,
causing 'tree-sitter-nim' dependency errors during cargo build.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use of SSH would require setting up SSH keys on our CI machines which would be
complicated. We standardize on HTTPS URLs instead
The parser.c file is gitignored in tree-sitter-nim and must be
generated before cargo build. This was handled in the Nix shell
hook but not in the non-nix-build flow used by CI's dmg-build.

Add parser generation to build_db_backend.sh:
- Installs tree-sitter CLI via npm if not available
- Generates parser.c only if missing or outdated
- Mirrors the logic from libs/tree-sitter-nim/Justfile

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Set up pre-commit hooks using git-hooks-nix flake module, following
the pattern from codetracer-rr-backend.

Hooks enabled:
- nixfmt-rfc-style: Format Nix files
- shellcheck: Lint shell scripts
- trim-trailing-whitespace: Remove trailing whitespace
- end-of-file-fixer: Ensure files end with newline
- check-yaml: Validate YAML syntax
- check-added-large-files: Prevent large file commits
- check-merge-conflict: Detect merge conflict markers
- check-submodule-https-urls: Ensure submodule URLs use HTTPS
  (required for Nix access-tokens authentication in CI)

The hooks are automatically installed when entering the dev shell,
and .pre-commit-config.yaml is symlinked to the Nix store.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add additional pre-commit hooks following codetracer-rr-backend patterns:
- shfmt: Shell script formatter
- taplo: TOML formatter (for Cargo.toml etc.)
- cspell: Spell checker for markdown files
- markdownlint-cli2: Markdown linter with auto-fix

Also adds:
- .cspell.json: Spell checker configuration
- project-words.txt: Custom dictionary for project-specific terms

Rust hooks (clippy, cargo-check, rustfmt) are commented out due to
nixpkgs version compatibility issues with git-hooks-nix. Can be
enabled later when versions are aligned.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace &PathBuf with &Path in function signatures (ptr_arg lint)
- Use std::slice::from_ref instead of cloning for single-element slices
- Fix duplicate condition in boolean expression (nonminimal_bool)
- Replace redundant closures with function references
- Remove needless borrows
- Add #[allow] attributes for intentional patterns:
  - too_many_arguments where refactoring would reduce clarity
  - expect_used/unwrap_used for internal invariants
  - wrong_self_convention for methods that need &mut self
  - dead_code/unused_variables in test harness
- Add test module allows for unwrap/expect/panic in test code
- Apply rustfmt formatting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 115+ project-specific words to cspell dictionary
- Add ignore paths for spec files and planning documents in .cspell.json
- Extend markdownlint excludes for legacy docs, internal notes, and
  implementation plans with varied formatting
- Fix typo "Installating" -> "Installing" in README.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Refactor patchelf commands into a loop with shellcheck disable
  comment for SC2016 ($ORIGIN is an ELF rpath token, not a shell var)
- Fix typo "Installating" -> "Installing" in README.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Auto-formatted by shfmt pre-commit hook for consistent shell script style.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Auto-formatted by taplo pre-commit hook for consistent TOML style.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove deprecated mdbook-alerts from shell files (now native in mdbook)
- Update flake.lock with latest inputs
- Apply nixfmt formatting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Auto-formatted by pre-commit hooks:
- trim-trailing-whitespace on markdown and text files
- end-of-file-fixer ensuring files end with newline
- Minor formatting adjustments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When cspell checks files in batches and all files in a batch are
excluded by ignorePaths, it returns exit code 1 (no files found).
The --no-must-find-files flag suppresses this error for empty batches.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Rust hooks (clippy, cargo-check) need git submodules which aren't
available in the Nix sandbox during flake check. Disable the pre-commit
check output while keeping hooks working in dev shell and git commits.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@zah zah force-pushed the nix-mac-compatibility branch from edd75d0 to b29da8b Compare February 1, 2026 04:51
zah and others added 7 commits February 3, 2026 10:35
Nix needs GitHub credentials in the netrc file to fetch private
submodules during flake evaluation with ?submodules=1.

The access-tokens config alone isn't sufficient - netrc is required
for git+https URLs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Node.js v25.4.0 (from macos-latest) has C++ header compatibility
issues with tree-sitter native module compilation. The [[nodiscard]]
attribute usage in v8-memory-span.h causes compilation failures.

Pinning to Node.js v20 (LTS) resolves this issue.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add install_node.sh script following the pattern of other install
scripts to pin Node.js to v20 (LTS). This ensures consistent behavior
across environments and avoids compatibility issues with newer Node.js
versions.

Changes:
- Add non-nix-build/install_node.sh to install Node.js v20 via brew
- Update env.sh to call install_node.sh instead of brew install node
- Remove node from the generic brew install line

This complements the GitHub Actions workflow fix by ensuring the
non-nix-build also uses a pinned Node.js version.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The dmg-build job sources env.sh which now calls install_node.sh,
so the explicit setup-node step in the workflow is redundant.

The build process is:
  ci/build/dmg.sh -> non-nix-build/build.sh -> source env.sh -> install_node.sh

So Node.js v20 is installed via install_node.sh before the build starts.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The parser.c file needs to be generated before yarn installs dependencies,
because yarn will try to build the tree-sitter-nim native addon which
requires parser.c to exist.

Build order was incorrect:
  Before: yarn install (fails) -> build_db_backend.sh generates parser.c
  After:  generate parser.c -> yarn install (succeeds)

The parser.c file is large and gitignored, so it must be generated from
grammar.js using 'tree-sitter generate' after checkout.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Change db-backend src from ../../src/db-backend to ../../.
- Use buildAndTestSubdir to specify the Cargo.toml location
- Add preBuild phase to generate parser.c if missing
- Add nodejs_20 to nativeBuildInputs for tree-sitter CLI

This fixes the nix-build failure where tree-sitter-nim submodule
was not available during Cargo build.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The buildRustPackage expects Cargo.lock and Cargo.toml at the source
root. Create symlinks from root to src/db-backend subdirectory so the
path dependencies (../../libs/tree-sitter-nim) resolve correctly.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
zah and others added 11 commits February 3, 2026 12:12
During Nix unpack phase, the source directory has a hash-based name,
not just "source". Use $sourceRoot variable to reference the correct
directory for tree-sitter-nim parser generation and symlinks.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove src/libs symlink with absolute path (breaks Nix builds)
- Remove auto-generated src/tup.config
- Add both to .gitignore along with .nix/ directory

The src/libs symlink pointed to an absolute path and caused Nix
builds to fail during codetracer-electron installPhase.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add pkgs.tree-sitter to nativeBuildInputs and use the binary directly
instead of npx which requires network access (disabled in Nix sandbox).

This fixes the EAI_AGAIN network error during parser generation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Set sourceRoot to src/db-backend subdirectory and create a symlink
to make libs/ accessible from within the subdirectory. This allows
Cargo path dependencies (../../libs/tree-sitter-nim) to resolve
correctly.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use mkDerivation instead of buildRustPackage to have full control
over the build process. This allows us to:
- Keep the full source tree available
- Generate tree-sitter-nim parser.c
- cd into src/db-backend before building
- Let Cargo path dependencies resolve correctly

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The cargoSetupHook expects Cargo.lock at the source root. Copy it
from src/db-backend/Cargo.lock during postUnpack phase.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add '--' separator before --skip arguments and remove '=' from skip
flags. The correct syntax is: cargo test -- --skip test_name

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When rustc is already present, the install script exits early without
ensuring rustup has a default toolchain configured. Add a check to
set the default to nightly if rustup is available.

This fixes the "rustup could not choose a version of rustc" error.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…igured

Move environment variable setup before rustc check and always call
rustup default nightly, both when exiting early and after fresh install.
Remove the 2>/dev/null that was hiding errors.

This ensures rustup has a default toolchain configured in all scenarios.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
npx requires the full package name. Change `npx tree-sitter` to
`npx tree-sitter-cli` so npx can find and install the package.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
These .nix/toolchain/ files are local development files that shouldn't
be tracked. The .nix/ directory is already in .gitignore.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@zah zah merged commit c11b7e6 into main Feb 3, 2026
26 checks passed
@zah zah deleted the nix-mac-compatibility branch February 3, 2026 13:14
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant