1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

Make nix flake info fix backwards compatible

This change handles previous nix versions by testing for the presence of
the `metadata` subcommand and falling back on the `info` subcommand if
it does not exist.
This commit is contained in:
Martin Hardselius 2021-03-22 20:58:51 +01:00
parent 93752a83ea
commit 4187519820
No known key found for this signature in database
GPG key ID: D25BE60D74E50F68

View file

@ -126,7 +126,13 @@ if [ -n "$flake" ]; then
fi
if [ -n "$flake" ]; then
flake=$(nix "${flakeFlags[@]}" flake metadata --json "${extraBuildFlags[@]}" "${extraLockFlags[@]}" -- "$flake" | jq -r .url)
if nix flake metadata &>/dev/null; then
cmd=metadata
else
cmd=info
fi
flake=$(nix "${flakeFlags[@]}" flake "$cmd" --json "${extraBuildFlags[@]}" "${extraLockFlags[@]}" -- "$flake" | jq -r .url)
fi
if [ "$action" != build ] && [ -z "$flake" ]; then