mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
use_nix: file was used in two places and values got confused
Using `file` in the for loop over the `nix_watches` entries left a value in `file`, so the check '[[ "$file" == ""]]' always failed. Found by adding `set -x` to `direnvrc` temporarily and staring hard at the output.
This commit is contained in:
parent
a18e37535d
commit
8ce0765b55
1 changed files with 10 additions and 8 deletions
18
direnvrc
18
direnvrc
|
|
@ -166,7 +166,8 @@ use_flake() {
|
|||
"$HOME/".direnvrc
|
||||
)
|
||||
|
||||
need_update=0
|
||||
local need_update=0
|
||||
local file=
|
||||
for file in "${nix_watches[@]}"; do
|
||||
if [[ "$file" -nt "$profile_rc" ]]; then
|
||||
need_update=1
|
||||
|
|
@ -248,7 +249,7 @@ use_nix() {
|
|||
local attribute=
|
||||
local packages=""
|
||||
local extra_args=()
|
||||
local file=
|
||||
local nixfile=
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
i="$1"
|
||||
shift
|
||||
|
|
@ -283,7 +284,7 @@ use_nix() {
|
|||
if [[ $in_packages == 1 ]]; then
|
||||
packages+=" $i"
|
||||
else
|
||||
file=$i
|
||||
nixfile=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
@ -298,6 +299,7 @@ use_nix() {
|
|||
)
|
||||
|
||||
local need_update=0
|
||||
local file=
|
||||
for file in "${nix_watches[@]}"; do
|
||||
if [[ "$file" -nt "$profile_rc" ]]; then
|
||||
need_update=1
|
||||
|
|
@ -318,19 +320,19 @@ use_nix() {
|
|||
extra_args+=("--expr" "with import <nixpkgs> {}; mkShell { buildInputs = [ $packages ]; }")
|
||||
else
|
||||
# figure out what file we should use
|
||||
if [[ "$file" == "" ]]; then
|
||||
if [[ "$nixfile" == "" ]]; then
|
||||
if [[ -e "shell.nix" ]]; then
|
||||
file="./shell.nix"
|
||||
nixfile="./shell.nix"
|
||||
elif [[ -e "default.nix" ]]; then
|
||||
file="./default.nix"
|
||||
nixfile="./default.nix"
|
||||
fi
|
||||
fi
|
||||
|
||||
# figure out what attribute we should build
|
||||
if [[ "$attribute" == "" ]]; then
|
||||
extra_args+=("--file" "$file")
|
||||
extra_args+=("--file" "$nixfile")
|
||||
else
|
||||
extra_args+=("--expr" "(import ${file}).$}attribute}")
|
||||
extra_args+=("--expr" "(import ${nixfile}).$}attribute}")
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue