diff --git a/examples/rust/.test.sh b/examples/rust/.test.sh index 36f2e9e9f..49f154c89 100755 --- a/examples/rust/.test.sh +++ b/examples/rust/.test.sh @@ -9,5 +9,8 @@ if [[ "$(uname)" == "Darwin" ]]; then echo "$CFLAGS" | grep -- "-iframework $DEVENV_PROFILE/Library/Frameworks" fi +[[ "$CARGO_INSTALL_ROOT" == "$DEVENV_STATE/cargo-install" ]] +echo "$PATH" | grep -- "$CARGO_INSTALL_ROOT/bin" + cd app cargo run diff --git a/src/modules/languages/rust.nix b/src/modules/languages/rust.nix index e8d03c52a..d778e534d 100644 --- a/src/modules/languages/rust.nix +++ b/src/modules/languages/rust.nix @@ -67,6 +67,18 @@ in mkOverrideTools = lib.mkOverride (lib.modules.defaultOverridePriority - 1); in { + # Set $CARGO_INSTALL_ROOT so that executables installed by `cargo install` can be found from $PATH + enterShell = '' + export CARGO_INSTALL_ROOT=$(${ + lib.strings.escapeShellArgs [ + "${pkgs.coreutils}/bin/realpath" + "--no-symlinks" + "${config.devenv.state}/cargo-install" + ] + }) + export PATH="$PATH:$CARGO_INSTALL_ROOT/bin" + ''; + packages = (builtins.map (c: cfg.toolchain.${c} or (throw (error "toolchain.${c}"))) cfg.components) ++ lib.optional pkgs.stdenv.isDarwin pkgs.libiconv;