summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2018-01-13 23:40:04 +0100
committerDaiderd Jordan <daiderd@gmail.com>2018-01-13 23:46:55 +0100
commitbfac6569ab82bb026db9d68bd3435a05292646ec (patch)
treec862782e754cab59ab18c8355223b76bb0a8cb1a
parent977ed04a600c996ff75c047bc57aa79704ba5e59 (diff)
bootstrap: add fix for /etc/profile
Also skip channel creation if <darwin> is already configured.
-rwxr-xr-xbootstrap.sh83
1 files changed, 59 insertions, 24 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index 277bbe6..8b55d06 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -134,15 +134,17 @@ install(){
sudo_prompt || exit
# Link run directory
- echo "Setting up /run..."
if ! test -L /run; then
+ echo "Setting up /run..."
sudo ln -sfn private/var/run /run || exit
fi
# Fetch the nix-darwin repo
- echo -e ""$YELLOW"Configuring darwin channel..."$ESC""
- nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin || exit
- nix-channel --update || exit
+ if ! nix-instantiate --eval -E '<darwin>' &> /dev/null; then
+ echo -e ""$YELLOW"Configuring darwin channel..."$ESC""
+ nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin || exit
+ nix-channel --update || exit
+ fi
# Copy the example configuration
if [ ! -e "$HOME/.nixpkgs/darwin-configuration.nix" ]; then
@@ -152,6 +154,59 @@ install(){
chmod u+w "$HOME/.nixpkgs/darwin-configuration.nix" || exit
fi
+ if ! test -L /etc/bashrc; then
+ if ! grep /etc/static/bashrc /etc/bashrc &> /dev/null; then
+ while true; do
+ read -p "Would you like to configure /etc/bashrc? [y/n] " ANSWER
+ case $ANSWER in
+ y|Y)
+ echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
+ break
+ ;;
+ n|N)
+ break
+ ;;
+ *)
+ echo "Please answer 'y' or 'n'..."
+ ;;
+ esac
+ done
+ fi
+ fi
+
+ if ! test -L /etc/profile && grep -q 'etc/profile.d/nix-daemon.sh' /etc/profile; then
+ while true; do
+ read -p "Would you like to remove nix-daemon.sh configuration in /etc/profile? [y/n] " i
+ case "$i" in
+ y|Y)
+ cat <<-'EOF' | sudo patch -d /etc -p1 || exit
+diff --git a/profile b/profile
+index 3748e3b..36ad2cd 100644
+--- a/profile
++++ b/profile
+@@ -7,9 +7,3 @@ fi
+ if [ "${BASH-no}" != "no" ]; then
+ [ -r /etc/bashrc ] && . /etc/bashrc
+ fi
+-
+-# Nix
+-if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
+- . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
+-fi
+-# End Nix
+EOF
+ break
+ ;;
+ n|N)
+ break
+ ;;
+ *)
+ echo "Please answer 'y' or 'n'..."
+ ;;
+ esac
+ done
+ fi
+
# Bootstrap build using default nix.nixPath
echo "Bootstrapping..."
export NIX_PATH=darwin=$HOME/.nix-defexpr/channels/darwin:darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$NIX_PATH
@@ -191,26 +246,6 @@ install(){
done
fi
- if ! test -L /etc/bashrc; then
- if ! grep /etc/static/bashrc /etc/bashrc &> /dev/null; then
- while true; do
- read -p "Would you like to configure /etc/bashrc? [y/n] " ANSWER
- case $ANSWER in
- y|Y)
- echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
- break
- ;;
- n|N)
- break
- ;;
- *)
- echo "Please answer 'y' or 'n'..."
- ;;
- esac
- done
- fi
- fi
-
# Finish
echo -e ""$GREEN"You're all done!"$ESC""
echo -e "Take a look at "$YELLOW"~/.nixpkgs/darwin-configuration.nix"$ESC" to get started."