diff --git a/direnvrc b/direnvrc index d153bd7..4fe7708 100644 --- a/direnvrc +++ b/direnvrc @@ -86,6 +86,13 @@ _nix_add_gcroot() { ln -fsn "$symlink" "/nix/var/nix/gcroots/per-user/$USER/$escaped_pwd" } +_argsum_suffix() { + if [ -n "$1" ]; then + echo -n "-" + echo "$1" | shasum | cut -d' ' -f1 + fi +} + use_flake() { flake_expr="${1:-.}" flake_dir="${flake_expr%#*}" @@ -94,7 +101,7 @@ use_flake() { local layout_dir layout_dir=$(direnv_layout_dir) - local profile="${layout_dir}/flake-profile" + local profile="${layout_dir}/flake-profile$(_argsum_suffix "$flake_expr")" local flake_inputs="${layout_dir}/flake-inputs/" local profile_rc="${profile}.rc" @@ -209,7 +216,7 @@ use_nix() { version="${version_prefix}-${path:11:16}" fi - local cache="${layout_dir}/cache-${version:-unknown}" + local cache="${layout_dir}/cache-${version:-unknown}$(_argsum_suffix "$*")" local update_drv=0 if [[ ! -e "$cache"