2017-07-12 14:46:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-07-12 21:10:14 +00:00
|
|
|
set -eux
|
|
|
|
|
2017-07-12 14:46:29 +00:00
|
|
|
cleanup() {
|
|
|
|
PLIST="/Library/LaunchDaemons/org.nixos.nix-daemon.plist"
|
|
|
|
if sudo launchctl list | grep -q nix-daemon; then
|
|
|
|
sudo launchctl unload "$PLIST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$PLIST" ]; then
|
|
|
|
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
|
|
|
fi
|
|
|
|
|
|
|
|
profiles=(/etc/profile /etc/bashrc /etc/zshrc)
|
|
|
|
for profile in "${profiles[@]}"; do
|
|
|
|
if [ -f "${profile}.backup-before-nix" ]; then
|
|
|
|
sudo mv "${profile}.backup-before-nix" "${profile}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-07-13 00:29:58 +00:00
|
|
|
for file in ~/.bash_profile ~/.bash_login ~/.profile ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin; do
|
2017-07-13 00:31:33 +00:00
|
|
|
if [ -e "$file" ]; then
|
|
|
|
cat "$file" | grep -v nix-profile > "$file.next"
|
|
|
|
mv "$file.next" "$file"
|
|
|
|
fi
|
2017-07-13 00:29:58 +00:00
|
|
|
done
|
|
|
|
|
2017-07-12 14:46:29 +00:00
|
|
|
for i in $(seq 1 $(sysctl -n hw.ncpu)); do
|
|
|
|
sudo /usr/bin/dscl . -delete "/Users/nixbld$i" || true
|
|
|
|
done
|
|
|
|
sudo /usr/bin/dscl . -delete "/Groups/nixbld" || true
|
|
|
|
|
|
|
|
sudo rm -rf /etc/nix \
|
|
|
|
/nix \
|
|
|
|
/var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels \
|
2019-07-25 13:43:24 +00:00
|
|
|
"$HOME/.nix-profile" "$HOME/.nix-defexpr" "$HOME/.nix-channels"
|
2017-07-12 14:46:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
verify() {
|
2017-07-13 00:43:57 +00:00
|
|
|
set +e
|
2017-07-12 14:46:29 +00:00
|
|
|
output=$(echo "nix-shell -p bash --run 'echo toow | rev'" | bash -l)
|
2017-07-13 00:43:57 +00:00
|
|
|
set -e
|
|
|
|
|
2017-07-12 14:46:29 +00:00
|
|
|
test "$output" = "woot"
|
|
|
|
}
|
|
|
|
|
|
|
|
scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
function finish {
|
|
|
|
rm -rf "$scratch"
|
|
|
|
}
|
|
|
|
trap finish EXIT
|
|
|
|
|
|
|
|
# First setup Nix
|
|
|
|
cleanup
|
2020-09-12 20:08:40 +00:00
|
|
|
curl -L -o install https://nixos.org/nix/install
|
2017-07-13 21:22:54 +00:00
|
|
|
yes | bash ./install
|
2017-07-12 14:46:29 +00:00
|
|
|
verify
|
|
|
|
|
|
|
|
|
|
|
|
(
|
2017-07-13 00:43:57 +00:00
|
|
|
set +e
|
2017-07-12 21:10:14 +00:00
|
|
|
(
|
|
|
|
echo "cd $(pwd)"
|
|
|
|
echo nix-build ./release.nix -A binaryTarball.x86_64-darwin
|
|
|
|
) | bash -l
|
2017-07-13 00:43:57 +00:00
|
|
|
set -e
|
2017-07-12 14:46:29 +00:00
|
|
|
cp ./result/nix-*.tar.bz2 $scratch/nix.tar.bz2
|
|
|
|
)
|
|
|
|
|
|
|
|
(
|
|
|
|
cd $scratch
|
|
|
|
tar -xf ./nix.tar.bz2
|
|
|
|
|
|
|
|
cd nix-*
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
|
|
|
yes | ./install
|
|
|
|
verify
|
|
|
|
cleanup
|
|
|
|
|
2017-07-13 21:22:54 +00:00
|
|
|
echo -n "" | ./install
|
2017-07-12 14:46:29 +00:00
|
|
|
verify
|
2017-07-13 22:01:22 +00:00
|
|
|
cleanup
|
2017-07-12 14:46:29 +00:00
|
|
|
|
2017-07-13 22:01:22 +00:00
|
|
|
sudo mkdir -p /nix/store
|
|
|
|
sudo touch /nix/store/.silly-hint
|
2017-07-14 10:28:24 +00:00
|
|
|
echo -n "" | ALLOW_PREEXISTING_INSTALLATION=true ./install
|
2017-07-13 22:01:22 +00:00
|
|
|
verify
|
|
|
|
test -e /nix/store/.silly-hint
|
2017-07-13 23:03:35 +00:00
|
|
|
|
2017-07-12 14:46:29 +00:00
|
|
|
cleanup
|
|
|
|
)
|