bootstrap.sh
1 #!/usr/bin/env bash 2 # shellcheck disable=SC2143 3 4 if ! command -v nix &>/dev/null ; then 5 >&2 echo "❌ 'nix' not installed" 6 >&2 echo "Please go to: https://nixos.org/download.html" 7 >&2 echo "and use \"Nix: the package manager\" instructions to install it." 8 >&2 echo "Most likely you just need to run: 'sh <(curl -L https://nixos.org/nix/install) --daemon'" 9 >&2 echo "" 10 >&2 echo "Re-run $0 after 'nix' is installed" 11 echo 12 >&2 echo "✔️ 'nix' installed" 13 fi 14 15 if [ -e ".direnv" ] ; then 16 >&2 echo "✔️ 'direnv allow' set" 17 else 18 >&2 echo "❌ 'direnv allow' not set - not critical (please run 'direnv allow')" 19 fi 20 21 if [ -z "$(nix show-config | grep experimental-features | grep flakes)" ] || [ -z "$(nix show-config | grep experimental-features | grep nix-command)" ] ; then 22 >&2 echo "❌ Nix flakes not enabled - not critical (add 'experimental-features = nix-command flakes' to '$HOME/.config/nix/nix.conf')" 23 nix_cmd="nix --experimental-features 'nix-command flakes'" 24 else 25 >&2 echo "✔️ Nix flakes enabled" 26 nix_cmd="nix" 27 fi 28 29 if [ -z "$(nix show-config | grep substituters | grep fedimint)" ]; then 30 >&2 echo "❌ Fedimint CI binary cache not enabled - not critical (run '$nix_cmd develop .#bootstrap -c cachix use fedimint')" 31 else 32 >&2 echo "✔️ Fedimint CI binary cache enabled" 33 fi 34 35 36 if [ -e "${CARGO_BUILD_TARGET_DIR:-$PWD/target}/debug/fedimintd" ]; then 37 >&2 echo "✅ fedimintd built already" 38 else 39 >&2 echo "✅ Use '$nix_cmd develop' to start the dev shell in another window, while the project is being pre-built below..." 40 $nix_cmd develop -c cargo check -q 41 $nix_cmd develop -c cargo build -q 42 fi 43 44 >&2 echo "" 45 >&2 echo "Bootstrap complete." 46 >&2 echo "Use '$nix_cmd develop' to start the dev shell"