Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Samir-Rashid
Copy link
Contributor

Pull Request Overview

I simplified the shell.nix to use the rust-toolchain.toml when deciding what Rust targets and extensions are needed. In order to do this, I switched from the Mozilla Rust overlay to rust-overlay. This simplifies the toolchain and removes an issue where the previous toolchain version parsing would fail for non-nightly Rust versions.

I have also bumped Tockloader to 1.11.0.

Testing Strategy

make prepush worked in nix-shell. I have NOT tested flashing with the new Tockloader version.

TODO or Help Wanted

No

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

CC maintainers: @lschuermann

@Samir-Rashid
Copy link
Contributor Author

I had a hell of a time trying to get my first Tock program flashed after trying on NixOS and MacOS. Can I get approval to add some instructions into the shell.nix so people don't have to go on an Odyssey wondering why flashing isn't working successfully.

# If your board requires J-Link to flash, add these lines to your system wide configuration.

# Enable udev rules from jlink package
# services.udev.packages = [
#     pkgs.segger-jlink
# ];

# Add "segger-jlink" to your system packages and accept the EULA:
# nixpkgs.config.segger-jlink.acceptLicense = true;

@Samir-Rashid Samir-Rashid changed the title Update nix shell shell.nix: use rust-overlay Oct 31, 2023
@lschuermann
Copy link
Member

I'm sorry to hear that you did not have a great experience getting started with Tock development on NixOS.

Can I get approval to add some instructions into the shell.nix

Sure, this seems like a good addition to me. I do want to emphasize that this is the required toolchain setup for one particular series of boards (which we happen to use as de-facto reference boards). Other boards will have their own toolchain requirements, which may be proprietary (in which case we don't want to blindly accept EULAs etc.) and/or require system-wide configuration changes (e.g. udev rules). More documentation seems strictly better though.

I simplified the shell.nix to use the rust-toolchain.toml when deciding what Rust targets and extensions are needed. In order to do this, I switched from the Mozilla Rust overlay to rust-overlay.

Regarding this change, I'm slightly skeptical. This is the first time I'm hearing of oxalica's Rust overlay. A nice property of all of the Nix infrastructure in Tock right now is that it is moderately self-contained, and only pulls in "official" sources (i.e. Nixpkgs & Mozilla's rust-overlay). As far as I can tell, this is just an improved version of Mozilla's overlay---in particular, the only benefit we'd get from it is removing the TOML parsing infrastructure from our own shell.nix. To me personally, that does not seem like a huge benefit. Are there any other benefits to using this overlay?

Using a non-"official" overlay brings trust and supply chain issues. What we should do, orthogonal to switching to a non-Mozilla overlay, is pin a specific revision and ensure that Tock's Nix closures do not pull in any non-pinned dependencies.

@Samir-Rashid
Copy link
Contributor Author

Thank you for the feedback. I had not considered the downstream effects of adding a dependency. I found that there is an official overlay provided by nix-community which I swapped to. I believe nix-community is official and is run by the same people as the whole Nixpkgs organization.

@lschuermann lschuermann changed the title shell.nix: use rust-overlay shell.nix: use fenix overlay Nov 1, 2023
@lschuermann
Copy link
Member

I believe nix-community is official and is run by the same people as the whole Nixpkgs organization.

While, to my knowledge, nix-community is orchestrated by a set of people that largely overlaps with Nixpkgs maintainers, its purpose is to be an incubator for projects that the main @NixOS organization does not want to explicitly & officially support. Take for example the Nix User Repository: https://github.com/nix-community/nur

At this point, I'm indifferent about switching. I don't see a huge benefit to using an alternative overlay, apart from outsourcing our 10s of lines of TOML parsing logic. The Mozilla overlay works(TM), and so why switch? I did skim over the fenix overlay, however, and its seems to be relatively lean, use an automatically generated manifest (great for reproducibility, bad if it ever were to lag behind upstream nightly releases). I don't want to stand in the way of progress, and so if this doesn't break anything I guess we might as well try this. If it doesn't work, we can always revert.

@alevy do you have any opinions on this?

Copy link
Member

@lschuermann lschuermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this merged. While we're at it (and given we're now trusting an additional source), lets pin the hash of this fenix expression.

@Samir-Rashid Samir-Rashid force-pushed the update-nix-shell branch 2 times, most recently from 5d19604 to 2c4e326 Compare November 9, 2023 11:31
@github-actions github-actions bot added component WG-Network In the purview of the Network working group. labels Nov 9, 2023
Replaced bespoke Rust toolchain parsing and Mozilla overlay with
nix-community rust-overlay.

Added J-Link installation instructions.
@github-actions github-actions bot removed component WG-Network In the purview of the Network working group. labels Nov 9, 2023
Copy link
Member

@lschuermann lschuermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes the smoketest on my local machine (can build a board & Tockloader runs).

@lschuermann lschuermann added this pull request to the merge queue Nov 9, 2023
Merged via the queue into tock:master with commit 4f9f66f Nov 9, 2023
@Samir-Rashid Samir-Rashid deleted the update-nix-shell branch November 9, 2023 17:26
@lschuermann lschuermann mentioned this pull request Jan 9, 2024
2 tasks
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