From 93752a83ea56efab7dcd14c77fe64c1d49a947ce Mon Sep 17 00:00:00 2001 From: Martin Hardselius Date: Sun, 21 Mar 2021 23:54:10 +0100 Subject: [PATCH 1/3] Fix nix flake info error Fixes "error: 'info' is not a recognised command'" Issue: #307 --- pkgs/nix-tools/darwin-rebuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/nix-tools/darwin-rebuild.sh b/pkgs/nix-tools/darwin-rebuild.sh index 6a1c4a92..8df59e0c 100644 --- a/pkgs/nix-tools/darwin-rebuild.sh +++ b/pkgs/nix-tools/darwin-rebuild.sh @@ -126,7 +126,7 @@ if [ -n "$flake" ]; then fi if [ -n "$flake" ]; then - flake=$(nix "${flakeFlags[@]}" flake info --json "${extraBuildFlags[@]}" "${extraLockFlags[@]}" -- "$flake" | jq -r .url) + flake=$(nix "${flakeFlags[@]}" flake metadata --json "${extraBuildFlags[@]}" "${extraLockFlags[@]}" -- "$flake" | jq -r .url) fi if [ "$action" != build ] && [ -z "$flake" ]; then From 41875198203fe58aedc7e7ef63fc5a50bb46e9c1 Mon Sep 17 00:00:00 2001 From: Martin Hardselius Date: Mon, 22 Mar 2021 20:58:51 +0100 Subject: [PATCH 2/3] 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. --- pkgs/nix-tools/darwin-rebuild.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/nix-tools/darwin-rebuild.sh b/pkgs/nix-tools/darwin-rebuild.sh index 8df59e0c..33602bfe 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 From 1f8eb9b128f9afcf84c521729d8a6b4ea5b59b91 Mon Sep 17 00:00:00 2001 From: Martin Hardselius Date: Tue, 23 Mar 2021 09:49:47 +0100 Subject: [PATCH 3/3] Add nix flags to subcommand test This change removes the need for having experimental-features = nix-command flakes in nix.conf. It should also work outside of flake directories. --- pkgs/nix-tools/darwin-rebuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/nix-tools/darwin-rebuild.sh b/pkgs/nix-tools/darwin-rebuild.sh index 33602bfe..3b4fb08f 100644 --- a/pkgs/nix-tools/darwin-rebuild.sh +++ b/pkgs/nix-tools/darwin-rebuild.sh @@ -126,7 +126,7 @@ if [ -n "$flake" ]; then fi if [ -n "$flake" ]; then - if nix flake metadata &>/dev/null; then + if nix "${flakeFlags[@]}" flake metadata --version &>/dev/null; then cmd=metadata else cmd=info