Merge pull request #12 from aaschmid/nix-2.4-compatibility

This commit is contained in:
Artturi 2022-01-02 19:10:39 +02:00 committed by GitHub
commit 05055c6a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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