27 lines
1004 B
Bash
27 lines
1004 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
echo "==> Checking for Nix..."
|
|
if ! command -v nix >/dev/null 2>&1; then
|
|
echo "==> Installing Nix vis Determinate Systems installer..."
|
|
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
|
|
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
|
else
|
|
echo "Nix already installed, skipping."
|
|
fi
|
|
|
|
echo "==> Copying config to /etc/nix-darwin..."
|
|
sudo mkdir -p /etc/nix-darwin
|
|
sudo cp -r "$(pwd)/." /etc/nix-darwin
|
|
sudo chown -R root:wheel /etc/nix-darwin
|
|
|
|
echo "==> Renaming conflicting shell files if present..."
|
|
[ -f /etc/bashrc ] && sudo mv /etc/bashrc /etc/bashrc.before-nix-darwin
|
|
[ -f /etc/zshrc ] && sudo mv /etc/zshrc /etc/zshrc.before-nix-darwin
|
|
[ -f /etc/zshenv ] && sudo mv /etc/zshenv /etc/zshenv.before-nix-darwin
|
|
|
|
echo "==> Bootstraping nix-darwin..."
|
|
nix run nix-darwin/master#darwin-rebuild -- switch --flake /etc/nix-darwin
|
|
|
|
echo "==> Done! Restart your terminal to apply all changes." |