SOLVED!
Hey everyone, I managed to solve the issue and wanted to share the solution.
The Main Reason: The whole problem was happening because I was trying to use rustup
(even though installed via Nix) alongside the Rust tools (rustc
, cargo
, rust-analyzer
, rustfmt
) also installed via Nix. The conclusion is: on NixOS, you generally shouldn't install rustup
if you're managing your Rust toolchain directly with Nix.
Explanation:
Nix/NixOS already does the "job" that rustup
would do on a traditional system, but in a declarative way that's integrated with the Nix package system. rustup
is designed to manage different Rust versions and components in its own directory (~/.rustup
), acting as a proxy for commands like rustc
, cargo
, etc.
When I installed rustup
via Nix, it was placed in the system path, but it still tried to act like rustup
, looking for toolchains managed by itself and expecting commands like rustup default stable
or rustup component add
.