mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
bootstrap: enable re-bootstrapping after a system upgrade
This commit is contained in:
parent
91a6785102
commit
c08fa97307
1 changed files with 24 additions and 20 deletions
44
bootstrap.sh
44
bootstrap.sh
|
@ -50,6 +50,10 @@ sanity(){
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -e /etc/static/bashrc ]]; then
|
||||||
|
. /etc/static/bashrc
|
||||||
|
fi
|
||||||
|
|
||||||
# Ensure Nix has already been installed
|
# Ensure Nix has already been installed
|
||||||
if [[ ! $(type nix-env 2>/dev/null) ]]; then
|
if [[ ! $(type nix-env 2>/dev/null) ]]; then
|
||||||
echo -e "Cannot find "$YELLOW"nix-env"$ESC" in the PATH"
|
echo -e "Cannot find "$YELLOW"nix-env"$ESC" in the PATH"
|
||||||
|
@ -61,7 +65,6 @@ sanity(){
|
||||||
# Check if nix-darwin is already present
|
# Check if nix-darwin is already present
|
||||||
if [[ $(type darwin-rebuild 2>/dev/null) ]]; then
|
if [[ $(type darwin-rebuild 2>/dev/null) ]]; then
|
||||||
echo -e "It looks like "$YELLOW"nix-darwin"$ESC" is already installed..."
|
echo -e "It looks like "$YELLOW"nix-darwin"$ESC" is already installed..."
|
||||||
[ ! -z $CREATE_DAEMON_USERS ] && create_daemon_users || exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +155,6 @@ install(){
|
||||||
# Bootstrap build using default nix.nixPath
|
# Bootstrap build using default nix.nixPath
|
||||||
echo "Bootstrapping..."
|
echo "Bootstrapping..."
|
||||||
export NIX_PATH=darwin=$HOME/.nix-defexpr/channels/darwin:darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$NIX_PATH
|
export NIX_PATH=darwin=$HOME/.nix-defexpr/channels/darwin:darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$NIX_PATH
|
||||||
$(nix-build '<darwin>' -A system --no-out-link)/sw/bin/darwin-rebuild build || exit
|
|
||||||
$(nix-build '<darwin>' -A system --no-out-link)/sw/bin/darwin-rebuild switch || exit
|
$(nix-build '<darwin>' -A system --no-out-link)/sw/bin/darwin-rebuild switch || exit
|
||||||
|
|
||||||
# Source generated bashrc
|
# Source generated bashrc
|
||||||
|
@ -189,22 +191,24 @@ install(){
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep /etc/static/bashrc /etc/bashrc &> /dev/null; then
|
if ! test -L /etc/bashrc; then
|
||||||
while true; do
|
if ! grep /etc/static/bashrc /etc/bashrc &> /dev/null; then
|
||||||
read -p "Would you like to configure /etc/bashrc? [y/n] " ANSWER
|
while true; do
|
||||||
case $ANSWER in
|
read -p "Would you like to configure /etc/bashrc? [y/n] " ANSWER
|
||||||
y|Y)
|
case $ANSWER in
|
||||||
echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
|
y|Y)
|
||||||
break
|
echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
|
||||||
;;
|
break
|
||||||
n|N)
|
;;
|
||||||
break
|
n|N)
|
||||||
;;
|
break
|
||||||
*)
|
;;
|
||||||
echo "Please answer 'y' or 'n'..."
|
*)
|
||||||
;;
|
echo "Please answer 'y' or 'n'..."
|
||||||
esac
|
;;
|
||||||
done
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Finish
|
# Finish
|
||||||
|
@ -227,13 +231,13 @@ main(){
|
||||||
local YELLOW='\033[38;33m'
|
local YELLOW='\033[38;33m'
|
||||||
local YELLOW_UL='\033[38;4;33m'
|
local YELLOW_UL='\033[38;4;33m'
|
||||||
|
|
||||||
init $@
|
init "$@"
|
||||||
sanity
|
sanity
|
||||||
install
|
install
|
||||||
}
|
}
|
||||||
|
|
||||||
# Actual run
|
# Actual run
|
||||||
main $@
|
main "$@"
|
||||||
|
|
||||||
|
|
||||||
} # Prevent execution if this script was only partially downloaded
|
} # Prevent execution if this script was only partially downloaded
|
||||||
|
|
Loading…
Add table
Reference in a new issue