diff options
| author | Martin Hardselius <martin@hardselius.dev> | 2021-03-22 20:58:51 +0100 |
|---|---|---|
| committer | Martin Hardselius <martin@hardselius.dev> | 2021-03-22 22:17:48 +0100 |
| commit | 41875198203fe58aedc7e7ef63fc5a50bb46e9c1 (patch) | |
| tree | ae296e6372e1080652230ea1d2755dee55cd88dc /pkgs | |
| parent | 93752a83ea56efab7dcd14c77fe64c1d49a947ce (diff) | |
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.
Diffstat (limited to 'pkgs')
| -rw-r--r-- | pkgs/nix-tools/darwin-rebuild.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkgs/nix-tools/darwin-rebuild.sh b/pkgs/nix-tools/darwin-rebuild.sh index 8df59e0..33602bf 100644 --- a/pkgs/nix-tools/darwin-rebuild.sh +++ b/pkgs/nix-tools/darwin-rebuild.sh @@ -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 |
