Using CLion + rust with rustup from nixpkgs - wrong toolchain path

Hi y’all! rustup from nixpkgs places cargo at /etc/profiles/per-user/<user>/bin/cargo (as a symlink) but Clion, i.e., the rust plugin, expects the toolchain at ~/.cargo/bin/cargo. What’s the most idiomatic way for Nix to overcome this issue?

  • a) patch rustup from nixpkgs to place a symlink at ~/.cargo/bin/cargo
  • b) automatically create a symlink in my configuration.nix, if it doesn’t exist
    • if so: how?
  • c) manually create the symlink

Manually patching the toolchain path for every of clion’s rust projects in the UI dialog is annoying.

What are your thoughts?

I’m interested in this one as well. My initial thought would be to let home-manager create a symlink to the relevant outputs of the rustup derivation.

The following solution works btw.

  home-manager.users.MY_USER = { pkgs, config, ... }: {
    # Link the location of the "cargo" proxy binary of rustup from nixpkgs to
    # the location where it is located with a regular rustup installation. 
    home.file.".cargo/bin".source = config.lib.file.mkOutOfStoreSymlink /etc/profiles/per-user/MY_USER/bin;