-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
executable file
·49 lines (38 loc) · 1.04 KB
/
bootstrap
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
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash -e
# bootstrap for macOS
check_cmd() {
command -v "$1" > /dev/null 2>&1
}
need_cmd() {
if ! check_cmd "$1"; then
err "command '$1' not found"
fi
}
msg() {
printf 'bootstrap: %s\n' "$1"
}
err() {
msg "$1" >&2
exit 1
}
macos() {
check_cmd nix || {
msg "installing Nix using Determinate Systems installer"
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
}
profile_sh=/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
[ -f $profile_sh ] && source $profile_sh
need_cmd nix
msg "bootstrap completed"
# will be replaced by generated flake versions
msg "moving /etc/nix/nix.conf (will be replaced)"
[ -f /etc/nix/nix.conf ] && sudo mv -f /etc/nix/nix.conf /etc/nix/nix.conf.before-nix-darwin
msg "moving /etc/shells (will be replaced)"
[ -f /etc/shells ] && sudo mv -f /etc/shells /etc/shells.before-nix-darwin
./rebuild
}
if [ "$(uname)" == "Darwin" ]; then
macos $@
else
echo "Unsupported operating system: $(uname)"
fi