2017-07-12 17:46:29 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-07-13 00:10:14 +03:00
|
|
|
set -eux
|
|
|
|
|
2017-07-12 17:46:29 +03: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 03:29:58 +03:00
|
|
|
for file in ~/.bash_profile ~/.bash_login ~/.profile ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin; do
|
2017-07-13 03:31:33 +03:00
|
|
|
if [ -e "$file" ]; then
|
|
|
|
cat "$file" | grep -v nix-profile > "$file.next"
|
|
|
|
mv "$file.next" "$file"
|
|
|
|
fi
|
2017-07-13 03:29:58 +03:00
|
|
|
done
|
|
|
|
|
2017-07-12 17:46:29 +03: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 16:43:24 +03:00
|
|
|
"$HOME/.nix-profile" "$HOME/.nix-defexpr" "$HOME/.nix-channels"
|
2017-07-12 17:46:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
verify() {
|
2017-07-13 03:43:57 +03:00
|
|
|
set +e
|
2017-07-12 17:46:29 +03:00
|
|
|
output=$(echo "nix-shell -p bash --run 'echo toow | rev'" | bash -l)
|
2017-07-13 03:43:57 +03:00
|
|
|
set -e
|
|
|
|
|
2017-07-12 17:46:29 +03: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 23:08:40 +03:00
|
|
|
curl -L -o install https://nixos.org/nix/install
|
2017-07-14 00:22:54 +03:00
|
|
|
yes | bash ./install
|
2017-07-12 17:46:29 +03:00
|
|
|
verify
|
|
|
|
|
|
|
|
|
|
|
|
(
|
2017-07-13 03:43:57 +03:00
|
|
|
set +e
|
2017-07-13 00:10:14 +03:00
|
|
|
(
|
|
|
|
echo "cd $(pwd)"
|
|
|
|
echo nix-build ./release.nix -A binaryTarball.x86_64-darwin
|
|
|
|
) | bash -l
|
2017-07-13 03:43:57 +03:00
|
|
|
set -e
|
2017-07-12 17:46:29 +03: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-14 00:22:54 +03:00
|
|
|
echo -n "" | ./install
|
2017-07-12 17:46:29 +03:00
|
|
|
verify
|
2017-07-14 01:01:22 +03:00
|
|
|
cleanup
|
2017-07-12 17:46:29 +03:00
|
|
|
|
2017-07-14 01:01:22 +03:00
|
|
|
sudo mkdir -p /nix/store
|
|
|
|
sudo touch /nix/store/.silly-hint
|
2017-07-14 13:28:24 +03:00
|
|
|
echo -n "" | ALLOW_PREEXISTING_INSTALLATION=true ./install
|
2017-07-14 01:01:22 +03:00
|
|
|
verify
|
|
|
|
test -e /nix/store/.silly-hint
|
2017-07-14 02:03:35 +03:00
|
|
|
|
2017-07-12 17:46:29 +03:00
|
|
|
cleanup
|
|
|
|
)
|