Skip to content

Commit

Permalink
build: hack around cargo bug
Browse files Browse the repository at this point in the history
Work around cargo which likes to jail break...

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
  • Loading branch information
tiagolobocastro committed Nov 4, 2024
1 parent 5145c86 commit d68d9f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 1 addition & 4 deletions nix/shell/ci.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{ pkgs }:
let
nixShellPurity = builtins.getEnv "IN_NIX_SHELL";
in
{
buildInputs = with pkgs; [
pre-commit
];

shellHook = ''
if [ -z "$CI" ] && [ "${nixShellPurity}" == "impure" ]; then
if [ -z "$CI" ] && [ "$IN_NIX_SHELL" == "impure" ]; then
echo "Installing CI pre-commit hooks..."
pre-commit install
pre-commit install --hook commit-msg
Expand Down
16 changes: 11 additions & 5 deletions nix/shell/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ let
echo "Target debug dir : $RUST_TARGET_DEBUG"
'';

rustCargoFix = ''
if [ -d $HOME/.cargo/bin ]; then
# Adding ~/.cargo/bin to the path let's us carry on using rustup but it lowers its
# priority: https://github.com/rust-lang/cargo/pull/11023
export PATH=$PATH:$HOME/.cargo/bin
fi
'';

configurations = {
# Stable Rust channel configuration.
stable = {
Expand All @@ -41,8 +49,7 @@ let

inherit shellEnv;

shellHook = ''
'';
shellHook = rustCargoFix;

shellInfoHook = ''
echo "Rust channel : stable"
Expand All @@ -58,8 +65,7 @@ let

inherit shellEnv;

shellHook = ''
'';
shellHook = rustCargoFix;

shellInfoHook = ''
echo "Rust channel : nightly (explicity selected)"
Expand Down Expand Up @@ -87,7 +93,7 @@ let
RUST_TARGET_DEBUG = "target/x86_64-unknown-linux-gnu/debug";
};

shellHook = ''
shellHook = rustCargoFix + ''
export LLVM_SYMBOLIZER_DIR=$(dirname $(realpath $(which llvm-symbolizer)))
'';

Expand Down
2 changes: 1 addition & 1 deletion scripts/rust-linter-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if [ -n "$RUST_NIGHTLY_PATH" ]; then
PATH=$RUST_NIGHTLY_PATH/bin:$PATH
# cargo attempts to search in ~/.cargo/bin first, so we need to put
# that at the end of the path as a quirky WA... sad :(
PATH=$PATH:~/.cargo/bin
PATH=$PATH:$HOME/.cargo/bin
fi

# Try cargo from PATH.
Expand Down

0 comments on commit d68d9f3

Please sign in to comment.