From 946b598054aedaebea955ae8b8e1568cb9b4cb43 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Sat, 7 Jun 2025 20:40:36 +0100 Subject: [PATCH] Add CARGO_HOME Signed-off-by: Nikolaos Karaolidis --- hosts/common/shells/rust/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hosts/common/shells/rust/default.nix b/hosts/common/shells/rust/default.nix index 6b44c5c..a438ecb 100644 --- a/hosts/common/shells/rust/default.nix +++ b/hosts/common/shells/rust/default.nix @@ -8,4 +8,15 @@ pkgs.mkShell { cargo-udeps cargo-outdated ]; + + shellHook = '' + if git rev-parse --is-inside-work-tree &> /dev/null; then + TOP="$(git rev-parse --show-toplevel)" + if ! grep -q "^\.cargo$" "$TOP/.gitignore" "$TOP/.git/info/exclude"; then echo ".cargo" >> "$TOP/.git/info/exclude"; fi + else + TOP="$(pwd)" + fi + + export CARGO_HOME="$TOP/.cargo" + ''; }