Merge pull request #308 from pinselimo/check-nix-version-directly

Check nix version directly
This commit is contained in:
Bryan Bennett 2023-03-02 10:19:59 -05:00 committed by GitHub
commit 9eda67e796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,8 +24,10 @@ _nix_direnv_preflight () {
exit 1
fi
if ! "${NIX_BIN_PREFIX}nix-shell" --extra-experimental-features '' --version 2>/dev/null >&2; then
log_status "nix-direnv: nix version is older than the required 2.4."
nixversion=$("${NIX_BIN_PREFIX}"nix --version)
[[ "$nixversion" =~ ([0-9]+)[^0-9]*([0-9]+)[^0-9]*([0-9]+)? ]]
if [[ "${BASH_REMATCH[1]}" -lt "2" || "${BASH_REMATCH[1]}" -eq "2" && "${BASH_REMATCH[2]}" -lt "4" ]]; then
log_status "nix-direnv: nix version ${BASH_REMATCH[0]} is older than the required 2.4."
exit 1
fi