add nix version 2.4 compatibility

Signed-off-by: Andreas Schmid <service@aaschmid.de>
This commit is contained in:
Andreas Schmid 2021-12-11 09:22:31 +01:00 committed by Artturin
parent 4a62ec17e2
commit f6f259214b

12
,
View File

@ -40,5 +40,15 @@ fi
if [[ -n $install ]]; then
nix-env -iA "nixpkgs.${attr%%.*}"
else
nix run "nixpkgs.${attr}" -c "${argv0}" "$@"
nix_version_greater_or_equal() {
local nix_version
nix_version=$(nix --version | cut -f3 -d ' ')
printf '%s\n%s' "$1" "$nix_version" | sort -C -V
}
if nix_version_greater_or_equal "2.4"; then
nix --extra-experimental-features 'nix-command flakes' shell "nixpkgs#${attr}" -c "${argv0}" "$@"
else
nix run "nixpkgs.${attr}" -c "${argv0}" "$@"
fi
fi