github.com/status-im/status-go@v1.1.0/nix/scripts/upgrade.sh (about) 1 #!/usr/bin/env bash 2 # This script upgrades Nix to specific version. 3 # https://nixos.org/manual/nix/stable/installation/upgrading.html 4 set -eo pipefail 5 6 GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) 7 source "${GIT_ROOT}/scripts/colors.sh" 8 source "${GIT_ROOT}/nix/scripts/lib.sh" 9 source "${GIT_ROOT}/nix/scripts/source.sh" 10 source "${GIT_ROOT}/nix/scripts/version.sh" 11 12 nix_upgrade() { 13 echo -e "Upgrading Nix interpreter to: ${GRN}${NIX_VERSION}${RST}" >&2 14 nix-channel --update 15 nix-env --install --attr "nixpkgs.${NIX_PACKAGE}" "nixpkgs.cacert" 16 nix_daemon_restart 17 } 18 19 # Allow for sourcing the script 20 if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then 21 return 22 fi 23 24 if [[ "$(nix_current_version)" == "${NIX_VERSION}" ]]; then 25 echo -e "Nix interpreter already on version: ${GRN}${NIX_VERSION}${RST}" 26 exit 0 27 fi 28 29 NIX_INSTALL_TYPE=$(nix_install_type) 30 if [[ "${NIX_INSTALL_TYPE}" == "nixos" ]]; then 31 echo -e "${YLW}WARNING:${RST} Upgrade Nix in your NixOS configuration!" >&2 32 exit 0 33 elif [[ "${NIX_INSTALL_TYPE}" == "single" ]]; then 34 nix_upgrade 35 elif [[ "${NIX_INSTALL_TYPE}" == "multi" ]]; then 36 sudo -i bash -c "source ${PWD}/${0}; nix_upgrade" 37 fi