mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-12-17 06:21:18 +01:00
get rid of gnugrep dependency
This commit is contained in:
parent
dff7b0bfe9
commit
5dc8842dbc
1 changed files with 17 additions and 3 deletions
20
direnvrc
20
direnvrc
|
|
@ -118,6 +118,21 @@ use_flake() {
|
||||||
_nix_export_or_unset TEMPDIR "$old_tempdir"
|
_nix_export_or_unset TEMPDIR "$old_tempdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_nix_extract_direnv() {
|
||||||
|
local found_direnv
|
||||||
|
found_direnv=0
|
||||||
|
while read -r line; do
|
||||||
|
if [[ "$found_direnv" == "1" ]]; then
|
||||||
|
echo "$line"
|
||||||
|
break
|
||||||
|
elif [[ "$line" == "_____direnv_____" ]]; then
|
||||||
|
found_direnv=1
|
||||||
|
else
|
||||||
|
echo "$line" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
use_nix() {
|
use_nix() {
|
||||||
local path layout_dir
|
local path layout_dir
|
||||||
path=$("${NIX_BIN_PREFIX}nix-instantiate" --find-file nixpkgs)
|
path=$("${NIX_BIN_PREFIX}nix-instantiate" --find-file nixpkgs)
|
||||||
|
|
@ -157,13 +172,12 @@ use_nix() {
|
||||||
then
|
then
|
||||||
[[ -d "$layout_dir" ]] || mkdir -p "$layout_dir"
|
[[ -d "$layout_dir" ]] || mkdir -p "$layout_dir"
|
||||||
local dump_cmd tmp
|
local dump_cmd tmp
|
||||||
dump_cmd="echo -n _____direnv_____; \"$direnv\" dump bash"
|
dump_cmd="echo _____direnv_____; \"$direnv\" dump bash"
|
||||||
tmp=$("${NIX_BIN_PREFIX}nix-shell" \
|
tmp=$("${NIX_BIN_PREFIX}nix-shell" \
|
||||||
"${experimental_flags[@]}" \
|
"${experimental_flags[@]}" \
|
||||||
--show-trace --pure "$@" --run "$dump_cmd")
|
--show-trace --pure "$@" --run "$dump_cmd")
|
||||||
# show original shell hook output
|
# show original shell hook output
|
||||||
echo "$tmp" | grep -vP '(?<=_____direnv_____).*'
|
echo "$tmp" | _nix_extract_direnv >&2 > "$cache"
|
||||||
echo "$tmp" | grep -oP '(?<=_____direnv_____).*' > "$cache"
|
|
||||||
update_drv=1
|
update_drv=1
|
||||||
else
|
else
|
||||||
log_status using cached derivation
|
log_status using cached derivation
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue