diff --git a/bootstrap.sh b/bootstrap.sh old mode 100644 new mode 100755 index 39ace02..803b9c8 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Bootstrapping nix and configuring nix to the point it can configure the rest # `chmod u+x` after git clone (change mode) to make file executable (+x) for current user (u) echo "Copying nix.conf to ~/.config/nix/" @@ -5,14 +6,18 @@ mkdir -p ~/.config/nix/ cp ./nix.conf ~/.config/nix/ echo "Downloading & verifying nix install script" -NIX_VERSION = "2.24.6" +NIX_VERSION=2.24.6 # --location follow redirect # --fail fail on bad HTTP code -INSTALL_SCRIPT = $(curl --location --fail -v https://releases.nixos.org/nix/nix-$NIX_VERSION/install) -ACTUAL_HASH = $(echo "$INSTALL_SCRIPT" | openssl dgst -sha256) -EXPECTED_HASH = "idk" -if ["$ACTUAL_HASH" != "$EXPECTED_HASH"]; then - echo "Error: Invalid hash for nix install script. Expected: $EXPECTED_HASH Got: $ACTUAL_HASH" +URL=https://releases.nixos.org/nix/nix-$NIX_VERSION/install + +INSTALL_SCRIPT=$(curl --location --fail -v "$URL") +ACTUAL_HASH=$(echo "$INSTALL_SCRIPT" | openssl dgst -sha256) + +EXPECTED_HASH=9f4535a9e90ab72874cf20ee1f9d41a130b16a56519dc3eec729540fcc78316f +# The whitespace in bash matters +if [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then + echo "Error: Invalid hash for nix install script. Version: $NIX_VERSION Expected: $EXPECTED_HASH Got: $ACTUAL_HASH" exit 1 else echo "Hash matches"