Make RustRover work with Rust from Nixpkgs

fix: rustup tools detection and clippy in nixpkgs

weethet.bsky.social c84798a1 de2b0b8c

verified
Changed files
+32 -7
src
+8 -3
default.nix
··· 78 78 )} 79 79 ''; 80 80 81 + tools = buildEnv { 82 + name = (args.name or "rr") + "-tools"; 83 + paths = addToToolchain; 84 + }; 85 + 81 86 cargoWrapper = writeShellScriptBin "cargo" '' 82 - export PATH="${rustc}/bin:$PATH" 87 + export PATH="${rustc}/bin:${tools}/bin:$PATH" 83 88 args=() 84 89 for arg in "$@"; do 85 90 if [[ "$arg" != +* ]]; then ··· 94 99 paths = [ 95 100 (lib.hiPrio cargoWrapper) 96 101 rustcWithRRLib 97 - ] 98 - ++ addToToolchain; 102 + tools 103 + ]; 99 104 }; 100 105 101 106 fakeRustup = writeShellScriptBin "rustup" ''
+24 -4
src/rustup.nu
··· 120 120 if ($rest | length) > 0 { 121 121 let subcmd = ($rest | first) 122 122 if $subcmd == "list" { 123 + let has_rustc = (which rustc | is-not-empty) 124 + let has_cargo = (which cargo | is-not-empty) 125 + let has_rustfmt = (which rustfmt | is-not-empty) 126 + let has_rust_analyzer = (which rust-analyzer | is-not-empty) 127 + let has_clippy = (which clippy-driver | is-not-empty) 128 + let has_miri = (which miri | is-not-empty) 129 + 123 130 if ($rest | length) > 1 and (($rest | get 1) == "--installed") { 124 131 print "rust-std" 125 - print "rustc" 126 - print "cargo" 132 + if $has_rustc { print "rustc" } 133 + if $has_cargo { print "cargo" } 134 + if $has_rustfmt { print "rustfmt" } 135 + if $has_rust_analyzer { print "rust-analyzer" } 136 + if $has_clippy { print "clippy" } 137 + if $has_miri { print "miri" } 127 138 } else { 128 139 print "rust-std (installed)" 129 - print "rustc (installed)" 130 - print "cargo (installed)" 140 + if $has_rustc { print "rustc (installed)" } else { print "rustc" } 141 + if $has_cargo { print "cargo (installed)" } else { print "cargo" } 142 + if $has_rustfmt { print "rustfmt (installed)" } else { print "rustfmt" } 143 + print "rust-docs" 144 + if $has_rust_analyzer { print "rust-analyzer (installed)" } else { print "rust-analyzer" } 145 + if $has_clippy { print "clippy (installed)" } else { print "clippy" } 146 + if $has_miri { print "miri (installed)" } else { print "miri" } 147 + print "rust-src (installed)" 148 + print "rust-mingw" 149 + print "llvm-tools" 150 + print "rustc-dev" 131 151 } 132 152 } 133 153 }