Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust): set $CARGO_INSTALL_ROOT and $PATH used in cargo install #721

Merged
merged 5 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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