Fix channel detection for rust-toolchain.toml #343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tl;dr
The current implementation assumes the presence of a key
datewhich is not part of thetoolchain.tomlformat. Instead, we need to parse thechannel's value to extract thedateandchannelfrom it to form a valid download URL.Problem
The overlay allows to specifiy a the path to
rust-toolchain.tomlto download the correct Rust toolchain. For this, the overlay uses the Nix builtin fromTOML to read the respective file. This function makes thekeys=valueof thetoolchainsection available. The current code assumes the presence of a key nameddatein thetoolchainsection. Rust toolchain files do not contain a key nameddate. Instead the date is part of thechannelsettings. As a result, the code evaluates toNULLfor the variabledatein the Nix code. For example, atoolchain.tomllooking like this:Leads to the generation of a invalid toolchain download URL, similar to:
In this case, the correct URL would be: https://static.rust-lang.org/dist/2024-01-24/channel-rust-nightly.toml
Proposed solution
Parse the
channelkey's value to obtain information about the channel (e.g. nightly) and the date.What's still missing?
My solution at this point only supports
channelvalues ofstable,betaandnightly. It needs to be extended to support versioned channels, but I currently lack the time to do so. Nevertheless, this should fix #287 and similar problems. That's why I though I should leave the fix here. Let me know if anything is missing, then I'll might look into it again in June.Have a nice week!