-
Notifications
You must be signed in to change notification settings - Fork 426
rust: fix toolchain creation with rust-overlay #2005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In the switch from fenix to rust-overlay, the final toolchain was not correctly patched. This resulted in runtime linker errors, where tools like clippy were linked against the wrong librustc. PR #1983 was an attempt at adjusting our APIs to better suit the toolchain/profile design of rust-overlay. This PR retains the API compatbility, at the cost of using private APIs.
Deploying devenv with
|
Latest commit: |
2c65a67
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5d1581ad.devenv.pages.dev |
Branch Preview URL: | https://fix-rust-overlay.devenv.pages.dev |
Claude finished @sandydoo's task —— View job Code Review CompleteReviewed PR #2005 for code quality, potential bugs, performance, security, and test coverage issues. Todo List
Areas for Improvement1. Private API Usage (High Priority)Issue: The code explicitly uses a private API from rust-overlay ( # WARNING: private API
# Import the mkAggregated function.
mkAggregated = import (rust-overlay + "/lib/mk-aggregated.nix") { Concerns:
Recommendation: Consider filing an issue upstream to expose this functionality publicly, or implement a more robust fallback mechanism. 2. Error Handling for Native Target (Medium Priority)Issue: The native target extraction at line 203 assumes nativeTarget = pkgs.stdenv.hostPlatform.rust.rustcTargetSpec; Concerns:
Recommendation: Add validation: nativeTarget = pkgs.stdenv.hostPlatform.rust.rustcTargetSpec or (throw "Unable to determine native Rust target for platform ${pkgs.stdenv.hostPlatform.system}"); 3. Component Resolution Logic (Medium Priority)Issue: The component resolution logic at lines 222-232 is complex and could be simplified. resolvedComponents = lib.map
(c:
let
resolvedName =
if builtins.elem c availableComponents then c
else if builtins.elem "${c}-preview" availableComponents then "${c}-preview"
else throw "Component '${c}' not found. Available: ${lib.concatStringsSep ", " availableComponents}";
in
cfg.toolchain.${c} or cfg.toolchain.${resolvedName} or toolchainComponents.${resolvedName}
)
cfg.components; Concerns:
Recommendation: Make the component resolution more explicit and add better error messages when components aren't found. 4. Attribute Access Safety (Low Priority)Issue: Several places use
Recommendation: Consider whether these fallbacks are appropriate or if they should fail more explicitly when manifest structure is unexpected. 5. Code Documentation (Low Priority)Issue: The complex logic around target handling and component resolution could benefit from more detailed comments. Recommendation: Add comments explaining:
Security Assessment
Test Coverage Implications
Overall AssessmentThe changes successfully address the linker errors by properly handling toolchain creation, but the reliance on private APIs and increased complexity introduce maintenance risks. The native target handling is a necessary improvement but could be more robust. |
896fe2f
to
b497811
Compare
b497811
to
f4d434a
Compare
devenv v1.7.0 is released, but it includes a bug that broke the rust toolchain creation (cachix/devenv#1983), so it is not usable for rust development at the moment. This commits pin devenv to v1.6.1 in the meantime.
In the switch from fenix to rust-overlay in #1500, the final toolchain was not correctly patched. This resulted in runtime linker errors, where tools like clippy were linked against the wrong librustc.
PR #1983 was an attempt at adjusting our APIs to better suit the toolchain/profile design of rust-overlay.
This PR retains the API compatibility at the cost of using private APIs.