-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmac
369 lines (301 loc) · 10.9 KB
/
mac
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#!/bin/sh
fancy_echo() {
_fmt="$1"; shift
# shellcheck disable=SC2059
printf "\\n$_fmt\\n" "$@"
}
# shellcheck disable=SC2154
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
if [ ! -f "$HOME/.zshrc" ]; then
touch "$HOME/.zshrc"
fi
# Determine Homebrew prefix
arch="$(uname -m)" # currently x86_64
if [ "$arch" = "arm64" ]; then
HOMEBREW_PREFIX="/opt/homebrew"
else
HOMEBREW_PREFIX="/usr/local"
fi
update_shell() {
shell_path="$(command -v zsh)"
fancy_echo "Changing your shell to zsh ..."
if ! grep "$shell_path" /etc/shells > /dev/null 2>&1 ; then
fancy_echo "Adding '$shell_path' to /etc/shells"
sudo sh -c "echo $shell_path >> /etc/shells"
fi
sudo chsh -s "$shell_path" "$USER"
}
case "$SHELL" in
*/zsh)
if [ "$(command -v zsh)" != "$HOMEBREW_PREFIX/bin/zsh" ] ; then
update_shell
fi
;;
*)
update_shell
;;
esac
# Check architecture
if [ "$arch" = "arm64" ]; then
# Check to see if Rosetta is already installed
if ! pkgutil --pkg-info=com.apple.pkg.RosettaUpdateAuto > /dev/null 2>&1 ; then
fancy_echo "Installing Rosetta2 ..."
softwareupdate --install-rosetta --agree-to-license
else
fancy_echo "Rosetta is installed"
fi
fi
if ! command -v brew >/dev/null; then
fancy_echo "Installing Homebrew ..."
/bin/bash -c \
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
export PATH="$HOMEBREW_PREFIX/bin:$PATH"
fi
fancy_echo "Updating Homebrew formulae ..."
brew update --force
# FYI: macOS 15 arm64 runner image already contains `awscli` formula installed
# See https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#tools
# Currently depends on `[email protected]`
# brew install --overwrite [email protected]
# brew install --overwrite awscli
# No need for a specific version of Python, always have Homebrew's `python3` in your `PATH`
# FYI: As of Oct 8, 2024 `python3` is aliased to `[email protected]`
# See https://github.com/Homebrew/homebrew-core/blob/master/Aliases/python3
# brew install --overwrite python3
brew bundle --file=- <<EOF
tap "thoughtbot/formulae"
tap "homebrew/services"
# Unix
brew "git"
brew "openssl"
brew "rcm"
# Starting w/ Big Sur, it's recommended to use "launchctl asuser ..." instead:
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/issues/78
# brew "reattach-to-user-namespace" # for copy-paste with tmux
brew "the_silver_searcher"
brew "tmux"
brew "vim"
brew "watch" # to execute a program periodically and show the output, can be ignored
brew "zsh"
# GitHub
brew "gh"
# Image manipulation
brew "imagemagick" # to crop and resize images
# Programming language prerequisites and package managers
brew "jemalloc"
brew "libyaml" # should come after OpenSSL
brew "coreutils"
brew "readline" # Ruby 3.3+ now uses Ruby-based reline instead
brew "node"
brew "yarn"
# Databases
brew "postgresql@17", restart_service: :changed
brew "redis", restart_service: :changed
tap "mongodb/brew"
EOF
if ! brew list -1 | grep mongodb-community ; then
brew install mongodb-community
fi
brew install chruby
# shellcheck disable=SC1091
. "$HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh"
if [ ! -d "$HOME/.rubies" ]; then
# https://www.ruby-lang.org/en/documentation/installation/#chruby
brew install ruby-install
ruby-install --update
fancy_echo "Configuring Ruby ..."
find_latest_ruby() {
# https://github.com/postmodern/ruby-install/blob/master/share/ruby-install/ruby-versions.sh#L83
tail -1 "$HOME/.cache/ruby-install/ruby/stable.txt"
}
ruby_version="$(find_latest_ruby)"
if ! chruby | grep -Fq "$ruby_version"; then
# https://github.com/postmodern/ruby-install?tab=readme-ov-file#synopsis
# https://github.com/postmodern/ruby-install/blob/master/share/ruby-install/ruby-install.sh#L33
# FYI: This will download the source code into ~/.cache/ruby-install/ rather than ~/src/.
# The "--with-opt-dir=$HOMEBREW_PREFIX/opt/jemalloc" option fixes the following error:
#
# checking for jemalloc/jemalloc.h... no
# checking for jemalloc.h... no
# configure: error: jemalloc requested but not found
# checking for jemalloc library... no
# !!! Configuration of ruby 3.4.1 failed!
#
ruby-install --no-reinstall \
--src-dir "$HOME/.cache/ruby-install" \
--install-dir "$HOME/.rubies/ruby-$ruby_version" \
--cleanup \
ruby "$ruby_version" -- \
"--with-openssl-dir=$HOMEBREW_PREFIX/opt/openssl" \
"--with-opt-dir=$HOMEBREW_PREFIX/opt/readline:$HOMEBREW_PREFIX/opt/libyaml:$HOMEBREW_PREFIX/opt/gdbm:$HOMEBREW_PREFIX/opt/jemalloc" \
"--with-jemalloc"
fi
fancy_echo "Setting default Ruby ..."
echo "$ruby_version" > "$HOME/.ruby-version"
# https://batsov.com/articles/2022/09/15/reload-zsh-configuration/
# shellcheck disable=SC1091
. "$HOME/.zshrc"
# After installing new Rubies, one must restart the shell before chruby can recognize them.
# https://github.com/postmodern/chruby#rubies-1
# chruby "$ruby_version" # won't work, only sets shell's $RUBY_VERSION to default Ruby
# Mimic shell restart
export RUBY_VERSION="$ruby_version"
# export RUBYOPT=
export RUBY_ENGINE=ruby
export RUBY_ROOT="$HOME/.rubies/ruby-$ruby_version"
export PATH="$RUBY_ROOT/bin:$PATH"
export GEM_HOME="$HOME/.gem/$RUBY_ENGINE/$RUBY_VERSION"
export GEM_ROOT="$RUBY_ROOT/lib/ruby/gems/$RUBY_VERSION"
export GEM_PATH="$GEM_HOME:$GEM_ROOT"
export PATH="$GEM_HOME/bin:$GEM_ROOT/bin:$PATH"
fancy_echo "Updating RubyGems ..."
gem update --system
fancy_echo "Installing Bundler ..."
gem install bundler
fancy_echo "Configuring Bundler ..."
# FYI: "nproc" is not installed by default, comes from "coreutils"
number_of_cores=$(nproc)
bundle config --global jobs $((number_of_cores - 1))
# https://bundler.io/v2.6/man/bundle-config.1.html
bundle config --global path ".bundle"
bundle config --global without production
# https://github.com/brianmario/mysql2#general-instructions
# https://github.com/brianmario/mysql2#mac-os-x
# bundle config --global build.mysql2 -- \
# --with-mysql-dir="$HOMEBREW_PREFIX/opt/mysql" --with-openssl-dir="$HOMEBREW_PREFIX/opt/openssl"
fi
# brew tap homebrew/bundle
fancy_echo "Installing oh-my-zsh ..."
if [ ! -d "$HOME/.oh-my-zsh/" ]; then
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
# In the past it was necessary to install Apple's XCode IDE to get
# basic tools like GCC, Git and Subversion on your machine, but
# nowadays there is a slim solution by just installing the command line tools
# FYI: macOS 15 arm64 runner image already contains XCode command line tools installed
# See https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#tools
if ! xcode-select -p > /dev/null 2>&1 ; then
fancy_echo "Installing XCode CLT ..."
xcode-select --install
fi
# FYI: macOS 15 arm64 runner image already contains `go` formula installed
# See https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#go
if ! brew list -1 | grep ^go$ ; then
fancy_echo "Installing Go ..."
brew install go
fi
brew bundle --file=- <<EOF
brew 'duff'
brew 'jq'
brew 'yq'
brew 'gist'
brew 'graphviz'
brew 'nmap'
brew 'tig'
brew 'dos2unix'
brew 'httpie'
brew 'shellcheck'
brew 'cloc'
brew 'wasmtime'
# https://nokogiri.org/tutorials/installing_nokogiri.html#installing-native-gems
# brew 'libxml2'
# brew 'libxslt'
cask 'iterm2'
brew 'java'
# Moved away from using no longer maintained 'elastic/tap':
# https://github.com/elastic/homebrew-tap/pull/126#issuecomment-1059264078
# tap 'dskecse/tap'
# brew '[email protected]'
# brew '[email protected]'
# brew 'kafka'
# cask 'emacs'
# cask 'mozart2'
# brew '[email protected]'
# FYI: Emacs comes w/ its own ctags, so this should be installed and linked after emacs.
# Currently fails:
# Possible conflicting files are:
# /usr/local/bin/ctags -> /Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_11/ctags
brew "universal-ctags" # index files for vim tab completion of methods, classes, variables
# Set up minimal Python3 development environment
cask 'google-cloud-sdk'
brew 'ghc'
brew 'cabal-install'
brew 'leiningen'
tap 'clojure/tools'
brew 'clojure'
tap 'hashicorp/tap'
brew 'hashicorp/tap/vault'
cask 'firefox'
# cask 'chromedriver' # FYI: A binary already exists in the system somehow.
cask 'ngrok'
cask 'wireshark'
cask 'dropbox'
# Specific version due to client-server compatibility issue
# brew '[email protected]'
brew 'kubernetes-cli'
brew 'kind'
brew 'helm'
# brew 'minikube'
# FYI: Docker Desktop starting w/ 4.25.0 no longer supports macOS Big Sur (11.7.10):
#
# You can't use this version of the application "Docker" with this version of macOS.
# You have macOS 11.7.10. The application requires macOS 12.0 or later.
#
# As per https://docs.docker.com/desktop/install/mac-install/:
#
# Docker supports Docker Desktop on the most recent versions of macOS.
# That is, the current release of macOS and the previous 2 releases.
#
# Up-to-date macOS versions list: https://support.apple.com/en-us/HT201260#latest
# Docker release notes: https://docs.docker.com/desktop/release-notes/
#
# cask 'docker'
# OrbStack: https://orbstack.dev/download
# Fast, light, powerful way to run containers
# Supports macOS 13.0+
cask 'orbstack'
cask 'tunnelbear'
cask 'openvpn-connect'
cask 'cyberduck' # upload media to S3 buckets
# FYI: Requires tmux.
# https://evilmartians.com/chronicles/introducing-overmind-and-hivemind
# brew 'overmind'
# Get set for native app development
# brew 'cocoapods'
# brew 'watchman'
brew 'gpg2'
# To get rid of "gpg: problem with the agent: Inappropriate ioctl for device"
# http://support.gpgtools.org/discussions/problems/42548-passphrase-window-not-shown
brew 'pinentry-mac'
# To only ever launch one instance of gpg agent and share the agents across
# every shell
# http://nullprogram.com/blog/2012/06/08/
brew 'keychain'
brew 'lame'
brew 'ffmpeg'
cask 'handbrake'
# brew 'postgis'
cask 'postico'
cask 'fliqlo'
EOF
if [ ! -d "$HOME/.vim/" ]; then
git clone https://github.com/dskecse/dotvim.git ~/.vim
ln -sf ~/.vim/vimrc ~/.vimrc
fi
# if [ ! -d "$HOME/.aws" ]; then
# aws configure
# AWS Access Key ID [None]:
# EOF when reading a line
# fi
gems_credentials_file="$HOME/.local/share/gem/credentials"
if [ ! -f "$gems_credentials_file" ]; then
mkdir -p "$(dirname "$gems_credentials_file")"
# Uses a new RubyGems POST /api/v1/api_key endpoint to create an API key.
# https://guides.rubygems.org/api-key-scopes/#migration-from-legacy-api-key
# Same as interactive `gem signin`, which creates ~/.local/share/gem/credentials
# requires the password from stdin, removes the line ":status: :ok" matching "status"
curl -u "$USER" -X POST -d "name=api-key&index_rubygems=true" \
https://rubygems.org/api/v1/api_key.yaml | sed '/status/d' > "$gems_credentials_file"
chmod 0600 "$gems_credentials_file"
fi