mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
Add a suffix to allow multiple calls to use_nix
This change permits to make multiple calls to use_nix, with different arguments passed to it. It will generate a cache file for each distinct "argument list" rather than based solely on the nixpkgs version.
This commit is contained in:
parent
34613e1e10
commit
9544919b4c
1 changed files with 9 additions and 2 deletions
11
direnvrc
11
direnvrc
|
|
@ -86,6 +86,13 @@ _nix_add_gcroot() {
|
||||||
ln -fsn "$symlink" "/nix/var/nix/gcroots/per-user/$USER/$escaped_pwd"
|
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() {
|
use_flake() {
|
||||||
flake_expr="${1:-.}"
|
flake_expr="${1:-.}"
|
||||||
flake_dir="${flake_expr%#*}"
|
flake_dir="${flake_expr%#*}"
|
||||||
|
|
@ -94,7 +101,7 @@ use_flake() {
|
||||||
|
|
||||||
local layout_dir
|
local layout_dir
|
||||||
layout_dir=$(direnv_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 flake_inputs="${layout_dir}/flake-inputs/"
|
||||||
local profile_rc="${profile}.rc"
|
local profile_rc="${profile}.rc"
|
||||||
|
|
||||||
|
|
@ -209,7 +216,7 @@ use_nix() {
|
||||||
version="${version_prefix}-${path:11:16}"
|
version="${version_prefix}-${path:11:16}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local cache="${layout_dir}/cache-${version:-unknown}"
|
local cache="${layout_dir}/cache-${version:-unknown}$(_argsum_suffix "$*")"
|
||||||
|
|
||||||
local update_drv=0
|
local update_drv=0
|
||||||
if [[ ! -e "$cache"
|
if [[ ! -e "$cache"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue