Macs
This document provides details on how to set up CRUK managed MacBooks.
Admin Access
Admin access. Admin access is a must. If you want to run sudo commands or update your /etc/hosts file you need admin access. For some unfathomable reason developer laptops are not provided with admin access as standard. You will need to create a ticket in Service Now and have it authorised by your line manager for EUC support (End User Computing) to enable your admin access. They can do this fairly quickly and remotely, they may require you to restart your machine. Then add your finger print to touch id in system settings.
Xcode & Command Line Tools
When installing Xcode from the App Store, disable windows defender restart your machine, download xcode and simply enable it after install. After download, install can take 3-5 hrs (ridiculous, I know) just leave it running. Alternatively, if only the Xcode Command Line Tools are needed (a requirement for git and homebrew etc) you can simple install Homebrew and you will be prompted with the option to install Xcode Command Line Tools.
Vagrant
If installing Vagrant you may run into issues if with IP ranges you need to use sudo commands to create the directories and file required below:
/etc/vbox/networks.conf
Add the following to that file (be careful blank spaces will break the file):
* 10.0.0.0/8 192.168.0.0/16
* 2001::/64
See Setting up vagrant for hosts only networking
Enabling NFS
If you want to use NFS you need to stop the firewall of the endpoint client for CheckPoint VPN from blocking it. Run:
sudo rm -rf /Library/Extensions/cpfw.kext
NFS will probably still be blocked until a restart
Terminal
zsh is now the default terminal for macs replacing bash, ohmyzsh is recommended as a way to manage plugins for zsh. See ohmyzsh inside your .zshrc file you might have something that looks like this:
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
iTerm2 is an improvement on the default terminal allowing for tabs and split screen views See iTerm2
See Setting up terminal guide (Note: This is now a Medium member's only article and thus requires a Medium account & subscription)
Homebrew
For everything that you can't get from the App Store, Homebrew is the de facto package manager for macs. To install brew run the following in terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Now you can start using brew to install plugins, libraries and applications for example:
brew install wget
See Homebrew
Node and nvm
It is highly likely that you will need the node runtime to do any web development, it is highly recommended not to install node but to install nvm (node version manager) via brew. To use brew setting up XCode as mentioned above is a pre-requisite.
brew install nvm
This is because different repos might depend on different versions of node and nvm gives you the ability to select different versions of node on the fly, for example to instal and use node 14:
nvm install 14
nvm use 14
See nvm
Husky + nvm
Husky is an node module which can universally across different operating systems setup git hooks for your repo. For example making sure it runs through specified linting checks before you commit your code. The reason why it is in this guide is because there are certain hoops that we need to jump though if we want this to tool to work with tools like vscode or source tree and nvm together if you use them to control your commits.
First, create a new file:
touch ~/.huskyrc
and inside add:
#!/usr/bin/env bash
source ~/.zshrc
if test -f ".nvmrc"; then
nvm use
fi
Add the following to your .zshrc file:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Passwords in terminal
For some reason, with these MacBooks entering passwords in terminal is really frustrating. When starting up multiple virtual machines in vagrant, for example, you may be requested to type in your password 10+ times; there are a few solutions to make this less painful.
The first is to enable touch id for terminal this can be done by editing /etc/pam.d/sudo
(requires sudo access to edit) and at the top of the file adding:
auth sufficient pam_tid.so
If using iTerm2, you will need an extra configuration. Go to Settings -> Advanced -> Allow sessions to survive logging out and back in
and set the value to no
.
See Enabling touch id in terminal
The second approach is to make every command in the terminal your user makes enabled as the super user - this can be done by running:
echo $(whoami)" ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$(whoami)
The first approach is recommended, and the second approach is only for people who can't use the touch bar. Both options are better than reducing the complexity of your password to make it more memorable.
References & Further Reading
- Configuring MacBook guide (https://sourabhbajaj.com/mac-setup/)