Watch nixfile in use_nix

This allows us to track the entry point the user specified
or whatever entry point we fallback to via auto-selection.

This should suprise fewer users.
Closes #197
This commit is contained in:
Bryan Bennett 2022-06-13 09:34:41 -04:00
parent bd76e52a97
commit ba0cbc1c07
No known key found for this signature in database
GPG key ID: EF90E3E98B8F5C0B

View file

@ -249,7 +249,14 @@ use_nix() {
local attribute=
local packages=""
local extra_args=()
local nixfile=
if [[ -e "shell.nix" ]]; then
nixfile="./shell.nix"
elif [[ -e "default.nix" ]]; then
nixfile="./default.nix"
fi
while [[ "$#" -gt 0 ]]; do
i="$1"
shift
@ -295,7 +302,9 @@ use_nix() {
esac
done
nix_direnv_watch_file "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc" .envrc default.nix shell.nix
# nixfile may be empty,
# but nix_direnv_watch_file checks for existance before adding to watches
nix_direnv_watch_file "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc" .envrc "$nixfile"
local need_update=0
local file=
@ -317,15 +326,6 @@ use_nix() {
if [[ "$packages" != "" ]]; then
extra_args+=("--expr" "with import <nixpkgs> {}; mkShell { buildInputs = [ $packages ]; }")
else
# figure out what file we should use
if [[ "$nixfile" == "" ]]; then
if [[ -e "shell.nix" ]]; then
nixfile="./shell.nix"
elif [[ -e "default.nix" ]]; then
nixfile="./default.nix"
fi
fi
# figure out what attribute we should build
if [[ "$attribute" == "" ]]; then
extra_args+=("--file" "$nixfile")