From 5a9e078e9e427abe8e320852ebeec400854dc601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 27 May 2025 09:12:04 +0200 Subject: [PATCH 1/2] drop nix version checks Fixes https://github.com/nix-community/nix-direnv/issues/582 Checks broke and we can simplify them by deleting. People that still have nix older than 2.4 in their PATH have to now set NIX_DIRENV_FALLBACK_NIX themselves. --- direnvrc | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/direnvrc b/direnvrc index 3668fb5..6e5f55a 100644 --- a/direnvrc +++ b/direnvrc @@ -6,7 +6,6 @@ NIX_DIRENV_VERSION=3.0.7 # min required versions BASH_MIN_VERSION=4.4 DIRENV_MIN_VERSION=2.21.3 -NIX_MIN_VERSION=2.4 _NIX_DIRENV_LOG_PREFIX="nix-direnv: " @@ -57,34 +56,6 @@ _require_cmd_version() { _require_version "$cmd" "${BASH_REMATCH[1]}" "$required" } -_nix_direnv_resolve_nix() { - local ambient_nix - - if ambient_nix=$(command -v nix); then - if _require_cmd_version "${ambient_nix}" "${NIX_MIN_VERSION}"; then - echo "${ambient_nix}" - return 0 - else - _nix_direnv_warning "Nix version in PATH is too old, wanted ${NIX_MIN_VERSION}+, got $(${ambient_nix} --version), will attempt fallback" - fi - else - _nix_direnv_warning "Could not find Nix in PATH, will attempt fallback" - fi - - if [ -n "${NIX_DIRENV_FALLBACK_NIX}" ]; then - if _require_cmd_version "${NIX_DIRENV_FALLBACK_NIX}" "${NIX_MIN_VERSION}"; then - echo "${NIX_DIRENV_FALLBACK_NIX}" - return 0 - else - _nix_direnv_error "Fallback Nix version is too old, wanted ${NIX_MIN_VERSION}+, got $(${NIX_DIRENV_FALLBACK_NIX} --version)" - return 1 - fi - else - _nix_direnv_error "Could not find fallback Nix binary, please add Nix to PATH or set NIX_DIRENV_FALLBACK_NIX" - return 1 - fi -} - _nix_direnv_preflight() { if [[ -z $direnv ]]; then # shellcheck disable=2016 @@ -104,7 +75,12 @@ _nix_direnv_preflight() { fi fi - if ! _nix_direnv_nix=$(_nix_direnv_resolve_nix); then + if command -v nix >/dev/null 2>&1; then + _nix_direnv_nix=$(command -v nix) + elif [[ -n ${NIX_DIRENV_FALLBACK_NIX:-} ]]; then + _nix_direnv_nix="${NIX_DIRENV_FALLBACK_NIX}" + else + _nix_direnv_error "Could not find Nix binary, please add Nix to PATH or set NIX_DIRENV_FALLBACK_NIX" return 1 fi From 03926f386414ab02235cd49e272055dfd0c16b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 27 May 2025 09:13:20 +0200 Subject: [PATCH 2/2] README: document requirements --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 036a0fc..0185c98 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ CPU load). ## Installation +Requirements: + +- bash 4.4 +- nix 2.4 or newer +- direnv 2.21.3 or newer + > [!WARNING]\ > We assume that [direnv](https://direnv.net/) is installed properly because > nix-direnv IS NOT a replacement for regular direnv _(only some of its