mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 11:36:11 +01:00
direnv_layout_dir is actually a function
This commit is contained in:
parent
ae191f0cd4
commit
a95abd152a
1 changed files with 6 additions and 7 deletions
13
direnvrc
13
direnvrc
|
|
@ -1,10 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
: "${direnv_layout_dir:=.direnv}"
|
||||
|
||||
use_nix() {
|
||||
local path
|
||||
path="$(nix-instantiate --find-file nixpkgs)"
|
||||
local path direnv_dir
|
||||
path=$(nix-instantiate --find-file nixpkgs)
|
||||
direnv_dir=$(direnv_layout_dir)
|
||||
|
||||
if [[ "${direnv:-}" == "" ]]; then
|
||||
log_status "\$direnv environment variable was not defined. Was this script run inside direnv?"
|
||||
|
|
@ -24,7 +23,7 @@ use_nix() {
|
|||
fi
|
||||
fi
|
||||
|
||||
local cache="${direnv_layout_dir}/cache-${version:-unknown}"
|
||||
local cache="$direnv_dir/cache-${version:-unknown}"
|
||||
|
||||
local update_drv=0
|
||||
if [[ ! -e "$cache" ]] || \
|
||||
|
|
@ -33,7 +32,7 @@ use_nix() {
|
|||
[[ default.nix -nt "$cache" ]] || \
|
||||
[[ shell.nix -nt "$cache" ]];
|
||||
then
|
||||
[[ -d "${direnv_layout_dir}" ]] || mkdir "${direnv_layout_dir}"
|
||||
[[ -d "$direnv_dir" ]] || mkdir "$direnv_dir"
|
||||
local dump_cmd tmp
|
||||
dump_cmd="echo -n _____direnv_____; \"$direnv\" dump bash"
|
||||
tmp=$(nix-shell --show-trace --pure "$@" --run "$dump_cmd" \
|
||||
|
|
@ -79,7 +78,7 @@ use_nix() {
|
|||
|
||||
# This part is based on https://discourse.nixos.org/t/what-is-the-best-dev-workflow-around-nix-shell/418/4
|
||||
if [[ "${out:-}" != "" ]] && (( update_drv )); then
|
||||
local drv_link="${direnv_layout_dir}/drv" drv
|
||||
local drv_link="${direnv_dir}/drv" drv
|
||||
drv=$(nix show-derivation "$out" | grep -E -o -m1 '/nix/store/.*.drv')
|
||||
local stripped_pwd=${PWD/\//}
|
||||
local escaped_pwd=${stripped_pwd//-/--}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue