Skip to content

packaging/nix-make: Rewrite the nushell builders in Python - #642

Merged
edolstra merged 2 commits into
mainfrom
python-builders
Sep 24, 2026
Merged

edolstra merged 2 commits into
mainfrom
python-builders

Conversation

@edolstra

@edolstra edolstra commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

The compile and link builders of the nix-make build (Nix as the C++ build system) were nushell scripts, chosen over bash because the structured attributes carry typed JSON (e.g. null and booleans in defines). Python has the same advantage, and unlike nushell it has full POSIX process control (signals, process groups, timeouts), which the functional test runner (tests/functional/run-tests.py) needs. Using Python for the builders too keeps all the build-system scripts in one language.

Context

compile.nu and link.nu become compile.py and link.py with the same logic; mkNuDerivation in lib.nix becomes mkPythonDerivation, and postInstall is now a Python snippet (run with out and os bound; the only user is src/nix/make.nix).

Measured on a real unit (116 includes), the builder's work before it execs the compiler drops from ~134 ms to ~28 ms: nushell has no ln builtin, so it forked one ln process per include, whereas Python creates the symlinks with system calls. Interpreter startup is comparable (9 ms vs 13 ms). Note that python3Minimal ships without bytecode caches, which makes it several times slower to start than python3, so the regular python3 is used.

Verified by a full rebuild of nix build ./packaging/nix-make#release.nix and by nix build ./packaging/nix-make#release.functional-tests (216 OK, 9 skipped).

Also includes a small AGENTS.md improvement.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated functional-test build instructions and clarified that non-optimized builds use the debug-fast configuration with clang and -O0.
  • Chores
    • Updated packaging build workflows to use Python-based compilation and linking tools instead of Nushell scripts.

compile.nu and link.nu become compile.py and link.py, and `postInstall` is now a Python snippet (with `out` and `os` bound). Python has the same advantage over bash for these builders (typed JSON for the structured attributes), and unlike nushell it has full POSIX process control, so the functional test runner can be written in it too, keeping all the build-system scripts in one language. As a side effect, compile.py creates the symlink tree of the includes with system calls rather than one `ln` process per include, which took ~100 ms per compilation unit.

Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Essentials

Run ID: 68faa32d-ff05-4a70-bf4a-cfebd9b7aeea

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd8b19 and 46613b7.

📒 Files selected for processing (7)
  • AGENTS.md
  • packaging/nix-make/compile.nu
  • packaging/nix-make/compile.py
  • packaging/nix-make/lib.nix
  • packaging/nix-make/link.nu
  • packaging/nix-make/link.py
  • src/nix/make.nix
💤 Files with no reviewable changes (2)
  • packaging/nix-make/link.nu
  • packaging/nix-make/compile.nu

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The Nix make derivation helper and compilation and linking builders now use Python instead of Nushell. The Nix configuration invokes the Python builders and uses Python for a post-install symlink. Build guidance also updates the functional-test command and non-optimized build example.

Changes

Nix make Python builders

Layer / File(s) Summary
Python derivation runner
packaging/nix-make/lib.nix
The derivation helper is renamed and runs supplied build scripts with Python 3. Python 3 replaces Nushell in nativeBuildInputs.
Compilation builder
packaging/nix-make/compile.py, packaging/nix-make/compile.nu, packaging/nix-make/lib.nix
The Python builder loads derivation attributes, prepares source and include paths, builds compiler flags, retrieves optional pkg-config flags, and invokes the compiler. The Nix configuration uses compile.py; compile.nu is removed.
Linking builder and post-install
packaging/nix-make/link.py, packaging/nix-make/link.nu, packaging/nix-make/lib.nix, src/nix/make.nix
The Python builder links libraries or executables, creates configured executable symlinks, and runs nonempty post-install snippets. The Nix configuration uses link.py; link.nu is removed. The documented and configured post-install snippets use Python.

Build guidance

Layer / File(s) Summary
Build command examples
AGENTS.md
The functional-test build command adds -L. The non-optimized build example uses debug-fast with clang and -O0.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 46613

No newly introduced issue identified here prevents merging. The pkg-config flag limitation predates this change.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing the Nushell Nix Make builders with Python builders.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request September 24, 2026 14:26 Inactive
@edolstra
edolstra added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit ed779ff Sep 24, 2026
36 checks passed
@edolstra
edolstra deleted the python-builders branch September 24, 2026 15:35

This branch was previously deployed

1 inactive deployment
pull request — 46613b75 Deployed Sep 24, 2026 by github-actions[bot]
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