-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·38 lines (29 loc) · 1.28 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·38 lines (29 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
set -euo pipefail
FLAKE="$HOME/.config"
xcode-select -p >/dev/null 2>&1 || {
xcode-select --install
echo "Install CLT."
exit 1
}
if [ ! -e /nix/var/nix/profiles/default/bin/nix ]; then
curl -sSfL https://artifacts.nixos.org/nix-installer | sh -s -- install --enable-flakes
fi
# shellcheck disable=SC1091
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
for f in bashrc zprofile zshrc nix/nix.conf; do
[ -e "/etc/$f" ] && [ ! -L "/etc/$f" ] && sudo mv "/etc/$f" "/etc/$f.before-nix-darwin"
done
if [ ! -f "$HOME/.config/nix/local.nix" ]; then
printf '{\n user = "%s";\n gitName = "";\n gitEmail = "";\n}\n' "$(whoami)" >"$HOME/.config/nix/local.nix"
echo "Created nix/local.nix from whoami; fill in gitName/gitEmail and re-run."
exit 1
fi
if grep -q '= ""' "$HOME/.config/nix/local.nix"; then
echo "nix/local.nix has empty fields; fill in gitName/gitEmail and re-run."
exit 1
fi
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command flakes" \
build "$FLAKE#darwinConfigurations.darwin.system" --impure --out-link /tmp/bootstrap-system
sudo env HOME="$HOME" /tmp/bootstrap-system/sw/bin/darwin-rebuild switch --flake "$FLAKE#darwin" --impure
"/etc/profiles/per-user/$(whoami)/bin/mise" install