-
Notifications
You must be signed in to change notification settings - Fork 89
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
Override compiler version #45
Comments
You can override the rust compiler by overlays to the used nixpkgs. I will investigate in making this easy... |
Would be cool to mention this in the readme with an example. I tried adding the mozilla overlay but I can't figure out, where do override the used compiler channel |
@vbrandl I am using the following pattern in an overlay: self: super: {
rustNightlyChannel = mozilla.rustChannelOf { date = "..."; channel = "..."; };
rustNightly = self.rustNightlyChannel.rust.override { extensions = [ "rust-src" ]; };
myBuildRustCrate = super.buildRustCrate.override { rustc = self.rustNightly; };
myPkg = (self.callPackage ./Crate.nix { buildRustCrate = myBuildRustCrate; }).rootCrate.build;
} (adopted from my actual, more complicated, version) |
Thank you. I also found this one yesterday but I didn't come around to test it, yet: https://github.com/jD91mZM2/xidlehook/blob/master/default.nix |
This answer is similar to @andir 's, but I just wanted to make explicit that you don't need to use an overlay. This is an example of a derivation using a nightly compiler: It's self-contained, so others can use the derivation directly. Edit: nevermind, I was still on a @kolloch maybe it's still worth pursuing this approach? It's more powerful than the |
I wasn't able to test yet because I didn't need it anymore (since 1.39.0 landed in the unstable channel, I don't need a nightly compiler for async/await). This can be closed but I think it would be nice to have a documented example in the README that shows how to use the mozilla overlay |
@andir @vbrandl @danielk I added documentation for doing this "globally" here: https://github.com/kolloch/crate2nix#choosing-a-rust-version I discovered one caveat: I had to use "rust" (without the c suffix) for "rustc" with a recent version of the overlay because otherwise Doing this globally is often what you want, I guess. Build all your stuff with the same rust compiler. But the individual approach also has merrit. Maybe you want to add that to the documentation? You would be welcome. @danielk for making buildRustCrate more directly overridable, see #77. Tell me what you think! For "pkgs" it is not the right tool, though, since you also want to override it for all dependencies, correct? |
I will close this issue for now but will gladly accept documentation fixes/extensions. |
How can I override, which rustc version or branch (stable/beta/nightly) to use?
Also it would be cool, if
crate2nix
would check forrust-toolchain
files which are used by rustup to pin a specific compiler version and or branch for a repository.The text was updated successfully, but these errors were encountered: