You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(rust): resolve architectural inconsistency in nixpkgs handling
## Problem
The rust kernel had an architectural inconsistency where it used two different
approaches to access nixpkgs packages:
1. **Module-level**: `requiredRuntimePackages = [config.nixpkgs.cargo ...]`
2. **Function-level**: `pkgs = import config.nixpkgs.path { ... }`
This caused evaluation failures when `config.nixpkgs.cargo` was undefined,
since users were only providing nixpkgs configuration (path + overlays)
rather than an instantiated package set.
## Root Cause Analysis
**Timeline of the inconsistency:**
- **Feb 9, 2023** (commit 9fc7d31): GuangTao Zhang introduced centralized
`config.nixpkgs` system. Rust kernel correctly used `config.nixpkgs.*`
- **Mar 16, 2023** (commit 0fea293): Dan Baker's "refactor/turn kernels into
modules" **accidentally combined two patterns**:
- Preserved module-level `config.nixpkgs.cargo` (correct for that system)
- Added function-level custom nixpkgs import (newer, more flexible approach)
- **July 19, 2025**: Recent improvements (commits 55655e3, 4d5f37c, e19f799)
enhanced flexibility but **inconsistency remained unfixed**
**Why it persisted:** The inconsistency was masked because module-level
`requiredRuntimePackages` usually overrode function-level defaults. Only
surfaced when users customized the kernel configuration.
## Solution
Updated `requiredRuntimePackages` to use the same `pkgs` instance that's
created with custom overlays, making the rust kernel architecturally
consistent:
```nix
# Before: Mixed approaches
requiredRuntimePackages = [config.nixpkgs.cargo ...]; # Uses config.nixpkgs
pkgs = import config.nixpkgs.path { overlays = ...; }; # Creates custom pkgs
# After: Consistent approach
pkgs = import config.nixpkgs.path { overlays = ...; }; # Create pkgs first
requiredRuntimePackages = [pkgs.cargo ...]; # Use same pkgs
```
This aligns the rust kernel with its own architectural pattern and eliminates
the dependency on `config.nixpkgs` being a package set.
## Testing
Verified the fix resolves evaluation errors in downstream projects that
configure rust kernels with custom nixpkgs paths and overlays.
Fixestweag#564
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
0 commit comments