Skip to content

Commit

Permalink
Merge pull request #721 from Atry/patch-4
Browse files Browse the repository at this point in the history
feat(rust): set `$CARGO_INSTALL_ROOT` and `$PATH` used in `cargo install`
  • Loading branch information
domenkozar authored Aug 27, 2023
2 parents 6b84a85 + df97eaf commit 68ea687
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/rust/.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions src/modules/languages/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 68ea687

Please sign in to comment.