From 9d2d51646879fae0f6141cfcff474051955b6cf6 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Tue, 11 Jul 2023 16:15:02 -0700 Subject: [PATCH 1/3] 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..762baaa15 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" + "${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; From bbb8eb22e24d79ed70e0bd0bb80f637a11ff6096 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Sat, 5 Aug 2023 14:21:16 -0700 Subject: [PATCH 2/3] Add tests --- examples/rust/.test.sh | 3 +++ 1 file changed, 3 insertions(+) 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 From df97eafc83dcad00ccbfa010e25708226a0a927f Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Sun, 27 Aug 2023 13:57:59 -0700 Subject: [PATCH 3/3] Reformat rust.nix --- src/modules/languages/rust.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/languages/rust.nix b/src/modules/languages/rust.nix index aa591983d..d778e534d 100644 --- a/src/modules/languages/rust.nix +++ b/src/modules/languages/rust.nix @@ -78,7 +78,7 @@ in }) 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;