From 62e93c107f2d34dc6e3f6cde1cc95c733b76703f Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Wed, 26 Mar 2025 20:39:34 +0800 Subject: [PATCH] nixos-option: Match the behavior described in detection order Set no_flake if $NIXOS_CONFIG is set or nixos-config= in $NIX_PATH --- pkgs/by-name/ni/nixos-option/nixos-option.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/ni/nixos-option/nixos-option.sh b/pkgs/by-name/ni/nixos-option/nixos-option.sh index 5690783c5657..d5d9b5b29f45 100644 --- a/pkgs/by-name/ni/nixos-option/nixos-option.sh +++ b/pkgs/by-name/ni/nixos-option/nixos-option.sh @@ -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