diff --git a/justfile b/justfile index 26d292139..5d8a5bd51 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,9 @@ scripts_dir := "scripts" +# Check if Nix is installed, if not install it based on the platform +install-nix: {{scripts_dir}}/install_nix.sh + @bash {{scripts_dir}}/install_nix.sh + # Check if Rust is installed, if not install it install-rust: @if ! command -v rustc &> /dev/null; then \ @@ -28,4 +32,4 @@ install-cosmo: . {{scripts_dir}}/update_path.sh; \ fi -all: install-rust install-wasm-target install-openssl install-cosmo +all: install-nix install-rust install-wasm-target install-openssl install-cosmo diff --git a/scripts/install_nix.sh b/scripts/install_nix.sh new file mode 100644 index 000000000..f3bd00c2a --- /dev/null +++ b/scripts/install_nix.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Check if Nix is installed +if ! command -v nix --help >/dev/null 2>&1; then + # Delete problematic backup files for bash and zsh if they exist + if [ -f "/etc/bash.bashrc.backup-before-nix" ]; then + sudo rm -f /etc/bash.bashrc.backup-before-nix + fi + + if [ -f "/etc/bashrc.backup-before-nix" ]; then + sudo rm -f /etc/bashrc.backup-before-nix + fi + + if [ -f "/etc/zshrc.backup-before-nix" ]; then + sudo rm -f /etc/zshrc.backup-before-nix + fi + + # Determine the platform (Linux or macOS) + case `uname` in + Linux*) + echo "Error: Nix package manager is not installed. Installing Nix for Linux..." + sh <(curl -L https://nixos.org/nix/install) --daemon + ;; + Darwin*) + echo "Error: Nix package manager is not installed. Installing Nix for macOS..." + sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume + ;; + *) + echo "Unsupported platform for Nix installation" + exit 1; + ;; + esac + +else + echo "Nix package manager is already installed." +fi