nixos-option: Match the behavior described in detection order

Set no_flake if $NIXOS_CONFIG is set or nixos-config= in $NIX_PATH
This commit is contained in:
Zhong Jianxin 2025-03-26 20:39:34 +08:00
parent 71f3af90d2
commit 62e93c107f

View File

@ -89,6 +89,10 @@ done
# `--no-flake`
# /etc/nixos/flake.nix (if exists)
if [[ -n "${NIXOS_CONFIG:-}" ]] || nix-instantiate --find-file nixos-config >/dev/null 2>&1; then
no_flake=true
fi
if [[ -z "$flake" ]] && [[ -e /etc/nixos/flake.nix ]] && [[ "$no_flake" == "false" ]]; then
flake="$(dirname "$(realpath /etc/nixos/flake.nix)")"
fi