Git Product home page Git Product logo

Comments (9)

andir avatar andir commented on June 25, 2024 3

@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)

from crate2nix.

vbrandl avatar vbrandl commented on June 25, 2024 1

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

from crate2nix.

kolloch avatar kolloch commented on June 25, 2024

You can override the rust compiler by overlays to the used nixpkgs.

I will investigate in making this easy...

from crate2nix.

vbrandl avatar vbrandl commented on June 25, 2024

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

from crate2nix.

vbrandl avatar vbrandl commented on June 25, 2024

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

from crate2nix.

cpcloud avatar cpcloud commented on June 25, 2024

@kolloch @vbrandl Can this be closed?

from crate2nix.

danieldk avatar danieldk commented on June 25, 2024

This answer is similar to @andir 's, but I just wanted to make explicit that you don't need to use an overlay.buildRustCrate, which is what the file generated by crate2nix uses, allows you to specify a whole Rust toolchain through the rust argument. This can be handy when you make a package set that others should also be able to use, without defining overlays locally.

This is an example of a derivation using a nightly compiler:

https://github.com/finalfusion/nix-packages/blob/cf8a4140d2359fb512608bde3c88ba410b5d94fb/pkgs/python-modules/finalfusion/default.nix

It's self-contained, so others can use the derivation directly.

Edit: nevermind, I was still on a crate2nix branch with PR #38, and I somehow misremembered that 184d3dd made this possible.

@kolloch maybe it's still worth pursuing this approach? It's more powerful than the defaultCrateOverrides argument introduced by 184d3dd. carnix also supports overriding buildRustCrate arguments. It's more intuitive than having to override buildRustCrate first and then passing the overrided buildRustCrate as an argument.

from crate2nix.

kolloch avatar kolloch commented on June 25, 2024

@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 rustc wouldn't find the std sources.

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?

from crate2nix.

kolloch avatar kolloch commented on June 25, 2024

I will close this issue for now but will gladly accept documentation fixes/extensions.

from crate2nix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.