From 8d801ac6aad749975455a34a9438ffb23f20d0a5 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Tue, 11 Jul 2023 16:15:02 -0700 Subject: [PATCH] Set `$CARGO_INSTALL_ROOT` and `$PATH` used in `cargo install` --- src/modules/languages/rust.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/languages/rust.nix b/src/modules/languages/rust.nix index 95d1e9db6..8d80693df 100644 --- a/src/modules/languages/rust.nix +++ b/src/modules/languages/rust.nix @@ -63,6 +63,19 @@ in config = lib.mkMerge [ (lib.mkIf cfg.enable { + + # 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" + "${devenvShellModule.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;