Override `rustc` in `makeRustPlatform`


I’m using mozilla’s Rust overlay to get a nightly Rust, and using that with makeRustPlatform. So I define the following in an overlay nix file:

muslTarget = rustChannel: rustChannel // {
    rust = rustChannel.rust.override (o: {
        targets    = o.targets or [] ++ ["x86_64-unknown-linux-musl"];
        extensions = o.extensions or [] ++ ["rust-src"];
(self: super: { 
    rustChannel = muslTarget (self.rustChannelOf {
        channel = "nightly";
        date    = "fake_date";
        sha256  = "fake_sha";

Which I then use finally with:

makeRustPlatform { cargo = rustChannel.rust; rustc = rustChannel.rust; }; 

However, I need to override rustc’s configureFlags, in order to enable a flag. Something like:

rustc = rustChannel.rustc.overrideAttrs (o: {
    configureFlags = o.configureFlags or [] ++ ["--enable-profiler"];

But as far as I can see, I can’t change rustc and rust inside of the rustChannel above. And if I only change rustc I end up with the default x86_64-unknown-linux-gnu target.

Is there any way in which I can change rustc from the rustChannel while also specifying the target?

Thanks in advance for any help.

1 Like