- 1 Security
- 2 Ergonomics
- 3 Desktop applications
- 4 Time Machine settings
- 5 Install XCode Command Line Tools (git and clang)
- 6 Install the Nix Package Manager
- 7 Using the Nix Package Manager
- 8 Install packages with Nix package manager
- 9 Shell configuration
- 10 Install Mamba
- 11 Python Anaconda distribution
- 12 Install R
- 13 Install Julia
- 14 (Optional) Assorted research and developer tools
-
Remove password quality restrictions
pwpolicy -clearaccountpolicies
-
Disable Global Protect VPN autostart https://www.robertsetiadi.com/disabling-globalprotect-vpn-auto-run-during-mac-start-up/
-
Manually kill and restart Global Protect VPN (via https://joshcurry.co.uk/posts/how-to-quit-globalprotect-mac/)
launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangp* launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*
Enable and activate stealth mode
-
If you have a
.ssh
directory in your old machine's home directory, copy the contents of that directory to your new machine using Magic Wormhole (this will require a Linux package manager; see Nix section below) -
Otherwise, create a new
.ssh
directory and generate a public/private key pair. On MacOS or Linux, open the Terminal application; on Windows 10, open the Powershell application. Then:cd ~/ mkdir .ssh ssh-keygen -t ed25519 -C "<your email address>"
- You will be prompted to enter a file name for the keys. Press Return to accept the default.
- You we be prompted to enter a passphrase. Type a passphrase and press Return (the Terminal will not display your password while you are typing).
-
Set permissions for .ssh directory and keys.
cd ~/ chmod 700 .ssh/ # .ssh directory cd .ssh/ chmod 600 * # private keys and other files chmod 644 *.pub # public keys
-
If you have more than one key pair, create a configuration file (
.ssh/config
) that lists the resolution order for the keys. Thessh
command will try the keys in order until one succeeds. The contents ofconfig
should follow this template:IdentityFile ~/.ssh/<key_file_1> IdentityFile ~/.ssh/<key_file_2> # et cetera
The best approach on Windows is probably to use the Github Credential Manager: https://github.com/GitCredentialManager . It's difficult to find clear guidance on how to set file permissions for .ssh/ and its contents.
Configure in System Preferences → Network → WiFi → Advanced → DNS
9.9.9.9
2620:fe::fe
2620:fe::9
8.8.8.8
duckduckgo.com
google.com
Configure in System Preferences → Privacy & Security
- Accessibility tab
- Terminal
- Emacs
- Full Disk Access tab
- Terminal
- Emacs
- Developer Tools tab The "Developer Tools" tab will appear when you run the command to enable developer mode for the terminal (step 1 below)
-
Terminal
# Enable Developer Tools tab and add Terminal to it sudo spctl developer-mode enable-terminal
-
Emacs
-
Coreutils version of ls (once installed)
-
ispell (once installed)
-
movemail (once installed)
-
nix (once installed)
-
Download and install DejaVu fonts
-
Settings → Keyboard: Key Repeat = Fast
-
Settings → Keyboard: Delay Until Repeat = Short
-
Settings → General: Disable iCloud handoff
-
Disable Bluetooth (or unplug all USB devices, depending on input source)
-
Disable accents pop-up menu
defaults write -g ApplePressAndHoldEnabled -bool false
via https://news.ycombinator.com/item?id=39528809 Each integer on the scale == 15 ms
# "Set a blazingly fast keyboard repeat rate, "
# Default fastest value = 2 (30 ms)
defaults write NSGlobalDomain KeyRepeat -int 1
# "Set a shorter Delay until key repeat"
# Default shortest value = 15 (225 ms)
defaults write NSGlobalDomain InitialKeyRepeat -int 10
# disable accents on key hold
defaults write -g ApplePressAndHoldEnabled -bool false
Reboot after setting the values. Don't ever change repeat rate in Preferences dialog, it resets it to the
- Display URL on mouseover View menu → Show status bar
- Install extensions
- 1Password
- AdGuard
- Box Tools
- Pinboard Tools
- Zotero Connector
- Stay signed out of office
- Tweak privacy settings: https://docs.microsoft.com/en-us/deployoffice/privacy/mac-privacy-preferences
- Nix disk partition
- ~/Library/CloudStorage
- ~/Google Drive mirrored directory name
-
List backups
tmutil listbackups
-
Delete selected backup
# Delete /Volumes/LaCie/Backups.backupdb/Hermes/2023-03-13-101503 sudo tmutil delete -d /Volumes/LaCie -t 2023-03-13-101503
-
References
You can install Git on your Mac using one of the following methods (we list more than one method because sometimes your permission settings will prevent one of the methods from working. Start at the top of the list and work your way down).
-
Method 1: Install from the terminal
xcode-select --install # Follow on-screen prompts to install
-
Method 2: Install from the terminal
clang --version # Follow on-screen prompts to install
-
Method 3: Manually download the latest version of "Command Line Tools for XCode" from https://developer.apple.com/download/more/
This shouldn't be necessary most of the time; the normal MacOS update process should also offer updates to the command line tools when they are available.
-
Search for software updates
softwareupdate --list
-
Install using full name
softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1"
Following https://www.philipp.haussleiter.de/2020/04/fixing-nix-setup-on-macos-catalina/
-
Verify that your file system is APFS
diskutil list | grep APFS
-
Create a new APFS disk volume called "nix" using Disk Utility
-
Create a mount point by adding the volume name to /etc/synthetic.conf:
nix
-
Reboot. This will create the "/nix" mount point.
-
Get the disk volume partition for the /nix mount point.
diskutil list | grep APFS | grep nix
-
Use the volume partition number to find its UUID
diskutil info /dev/disk1s6 | grep UUID
-
Create and edit /etc/fstab, preferably using vifs (note that vifs uses vi keybindings). Be sure to use your UUID, not the UUID in the example.
sudo vifs
UUID=78012913-F18F-4CB5-9CF0-CFFBB609692C /nix apfs rw
-
Reboot.
-
Create a
.profile
file in your home directory if it doesn't already exist. -
Download the nix installation script from https://nixos.org/nix/install as "install.sh", then execute:
sh install.sh
-
Copy contents of
.profile
to.zshrc
(or rename.profile
to.zshrc
if it doesn't already exist)
NixOS implements reproducible builds using profiles (current) or flakes (experimental). These approaches don't work when using Nix as the package manager for a third-party system. Instead, we have to do imperative package management using the nix-env
family of commands.
Major Nix commands have separate documentation for each higher-order flag; e.g., nix-env
has separate man pages for nix-env --query
, nix-env --install
, etc.
-
To get a list of the higher-order flags, run:
nix-env --help
-
To get the man page for a specific flag, run:
# man page for `nix-env --query` man nix-env-query
nix-channel --update
This works for imperatively installed packages (installed with `nix-env -i`), but not for profiles or flakes.
# Show brief listing
nix-env -q
# Show complete installation profile
nix-env -q --json --meta
-
Show available packages matching the symbolic name. This will output the attribute path (
--attr-path
|-P
), which you can use to disambiguate between multiple versions of the package.nix-env -qasP coreutils
-PS nixpkgs.coreutils coreutils-9.4 --S nixpkgs.coreutils-prefixed coreutils-9.4
-
Show available packages matching the attribute path. This is much faster.
nix-env -qasA nixpkgs.coreutils
-PS coreutils-9.4
-
Show available packages matching a regular expression.
nix-env -qasP '.*LaTeXML.*'
--S nixpkgs.perl536Packages.LaTeXML perl5.36.3-LaTeXML-0.8.7 IPS nixpkgs.perl538Packages.LaTeXML perl5.38.2-LaTeXML-0.8.7
-
Show the package description
nix-env -qasA nixpkgs.coreutils --description
-PS coreutils-9.4 The GNU Core Utilities
-
-
Show the package location
nix-env -qasA nixpkgs.coreutils --drv-path
-PS coreutils-9.4 /nix/store/xaia11jsmshb2scm9v6g5fh103i8hlvb-coreutils-9.4.drv
-
Install package by symbolic name
nix-env -i emacs-26.3
-
Install package by attribute path
nix-env -iA nixpkgs.coreutils nix-env -iA nixpkgs.perl538Packages.LaTeXML
-
Remove package
nix-env -e <package>
-
Show which packages will be upgraded
nix-env -u --dry-run
-
Run the upgrade
nix-env -u
-
Delete and recreate symbolic links for apps (i.e. Emacs; see installation instructions for more details)
-
Restore Full-Disk Access privileges for updated apps
-
Run mandb to recreate man page database
sudo mandb -c
This usually isn't required.
nix upgrade-nix
-
Show list of installed generations
nix-env --list-generations
-
Remove previous generations by ordinal distance (option 1)
# Remove all but last 3 generations nix-env --delete-generations +3 nix-collect-garbage
-
Remove previous generations by age (option 2)
# Optionally, delete and collect garbage in one pass nix-collect-garbage --delete-older-than 60d
- adoptopenjdk-hotspot-bin
- age
- darcs (required for Emacs interaction with /usr/share/zsh/<version>/functions)
- fish (required for Derek's Emacs configuration)
- htop
- ispell (required for Emacs)
- magic-wormhole
- nano
- nodejs
- pandoc
- poppler-utils (required for Emacs)
- ripgrep (required for Emacs)
- ruby 3.14
- stow (required for managing dot files)
- tree
- wget
-
Emacs
-
Get the complete version information of all the package variants. Installing by the symbolic name may not get you the latest version.
nix-env -qasP emacs nix-env -i emacs-29.1
-
Create symbolic link from application location to Applications folder
sudo su cd /Applications/ ln -s /nix/var/nix/profiles/per-user/gilgamesh/profile/Applications/Emacs.app Emacs.app
-
If upgrading from a previous version
- Set
desktop-save-mode
to0
:- In the
lisp/init-local.el
file - In current session via EShell
- In the
- Rename
custom.el
tocustom.el.bak
- Delete session files:
.session
history
recentf
.emacs.desktop
.emacs.desktop.lock
- Restart Emacs (you will probably have to do this multiple times to get all of the libraries to compile)
- Once Emacs is fully updated and starts without error, reset
desktop-save-mode
to1
- Set
-
-
coreutils (required for Emacs) These instructions use the un-prefixed version of coreutils, thereby overwriting BSD utilities such as
ls
with the Linux coreutils for the normal user. The root user is unaffected and will continue to use the BSD versions-
Get complete version information for all of the package variants. We are looking for the un-prefixed version of the GNU/Linux utilities (e.g., the
ls
command will be installed asls
, notgls
).nix-env -qasP coreutils
-
Install un-prefixed version
nix-env -iA nixpkgs.coreutils
-
-
imagemagick
nix-env -i ghostscript nix-env -iA nixpkgs.imagemagick7
-
man-db (caches man pages for faster loading in Emacs)
-
Install man-db
nix-env -i man-db
-
Create /var/cache/man directory and set owner to logged in user
cd /var/ sudo mkdir cache/man sudo chown -R <user>:<group> cache/
-
Create database
sudo mandb # If the database becomes corrupt, recreate it: sudo mandb -c
-
-
LaTeXML
nix-env -qasP '.*LaTeXML.*' nix-env -qaA nixpkgs.perl538Packages.LaTeXML nix-env -iA nixpkgs.perl538Packages.LaTeXML
Clone the dot file repository https://github.com/devnich/dotfiles into your home directory and follow the installation instructions in the README. Note that some files (e.g., .zshenv
, .nix-channel
) may conflict with files you have already created during the setup process. If this happens, you should merge the contents of each "live" file into its respective repository version before running the stow
command.
Davis Data Lab review: At UC Davis, most of the DataLab, several professors, and also the HPC admins use and recommend (Micro)mamba. We're also making Micromamba the preferred tool for installing userland software on servers in one of our upcoming workshops. Mamba has 147 contributors on GitHub to Conda's 424 and both have around 5.5k stars, so I'm not particularly worried about development unexpectedly stopping. Micromamba (but not Mamba) gets rid of the need for a base environment, which makes it harder for newbies to break. And as one sample point, I've been using it locally and on HPC servers for at least a year now without any problems.
https://mamba.readthedocs.io/en/latest/
cf. https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html
-
Download and extract the latest release. For consistency with Anaconda, we are installing in the user's
opt/
directory.cd ~/opt # Download for macOS Intel (x86_64) curl -LOJ https://micro.mamba.pm/api/micromamba/osx-64/latest # Alternatively, download for macOS Silicon/M1 (ARM64) curl -LOJ https://micro.mamba.pm/api/micromamba/osx-arm64/latest # Extract the micromamba binary tar -xf <filename>.tar.bz2 bin/micromamba
-
Modify
.zshrc
to enablemicromamba
commands./bin/micromamba shell init -s zsh -p ~/micromamba
-
Restart terminal
Install Python 3 version. After installation, which python
should report that Python is installed in /Users/<your user name>/opt/anaconda3/bin/python
. If it reports the system Python location, copy the relevant lines from .bash_profile
to .zshrc
.
-
Deactivate Anaconda to use system Python or utilities
# Deactivate Anaconda install conda deactivate which python # outputs /usr/bin/python # Reactivate conda activate which python # outputs /Users/<user_name>/opt/anaconda3/bin/python
-
Create a virtual environment
-
Option 1: Create an environment with selected libraries
conda create -n <env name> google-api-python-client pandas
-
Option 2: Create an environment cloned from a preexisting environment
conda create -n <env name> --clone base
-
Option 3: Create an environment following a YAML spec
conda env create -f <env file name>.yml
-
-
Show environment
conda env list
-
Switch to environment
conda activate <env name>
-
Export current environment to YAML
conda env export > <env file name>.yml
-
Install additional software with
pip
Always do this last. Conda cannot correctly install or update an environment that has been touched bypip
.pip install search_sampler
-
Remove environment
conda env remove -n <env name>
-
References
-
Find new packages
conda search [-i/v] <package-name>
-
Install new packages
conda install <package-name>
-
Check for updates
conda update --all --dry-run
-
Update conda package manager (may also update other packages)
# conda update -n base conda conda update -n base -c defaults conda
-
Update default (base) environment
conda update --all
Install nbdime diff and merge tools in a Conda environment. You must use this environment for development and for Git actions.
-
Create a new Conda environment. For testing purposes, do this first; for non-believers, do this at the end.
conda create -n <env name> --clone base conda activate <env name>
-
Install nbdime
conda install nbdime
-
Option 1: Enable nbdime for user account This will add a
~/.config/git/attributes
file and update the user's.gitconfig
file (on MacOS and Linux)nbdime config-git --enable
-
Option 2. Enable nbdime for specific project This will add a
.gitattributes
file to the project and update the project's.git/config
file.nbdime config-git --enable --global
- https://nbdime.readthedocs.io/en/latest/installing.html
- https://nbdime.readthedocs.io/en/latest/vcs.html
- If installing Anaconda on a lab machine, choose the multi-user installation
- In a multi-user installation, you cannot start Jupyter Lab from the Anaconda Navigator launcher. There are two work-arounds:
-
Launch the Anaconda Powershell prompt and run
python -m jupyterlab
-
Launch Jupyter Notebook. Edit the notebook URL, replacing ```tree``` with ```lab```, and reload.
-
-
Install R from CRAN: https://cran.r-project.org
-
Install RStudio IDE: https://posit.co/products/open-source/rstudio/
-
Install XQuartz: https://www.xquartz.org
-
Use R language manager to install useful libraries
install.packages("tidyverse") # Required for building Hadley's Advanced R book install.packages(c("rmarkdown", "bookdown", "downlit", "lobstr", "sloop", "tinytex")) install.packages("devtools") devtools::install_github("hadley/emo") # Optional utilities install.packages("renv") install.packages("lintr")
-
If installing TinyTeX (Bookdown dependency for generating PDFs), change owner of "/usr/local/bin"
sudo chown -R `whoami`:admin /usr/local/bin
-
Install Jupyter kernel for R
-
Check whether R as a Jupyter kernel
jupyter kernelspec list
-
If R kernel not listed, install it
install.packages('IRkernel') IRkernel::installspec()
-
-
Update R packages. Do this after you update R.
update.packages(ask = FALSE)
-
Install binary: https://julialang.org/downloads/
-
Add Julia kernel to Jupyter Lab
using Pkg Pkg.add("IJulia")
-
Make Julia available in path
# Remove original /usr/local/bin/julia symlink if it exists ln -s /Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia
-
Remove old kernel version from Jupyter Lab
jupyter kernelspec list jupyter kernelspec uninstall <kernel-name>
c.f. https://bookdown.org/yihui/bookdown/build-the-book.html
-
Test for dependencies via repeated failure
bookdown::render_book()
-
Build the PDF
bookdown::render_book('index.Rmd', 'bookdown::pdf_book')
- Give full disk access to Terminal
- Go to System Preferences → Security & Privacy → Full Disk Access
- Check Terminal (or add with + if it doesn't already appear in the list of programs)
- Install XCode Command Line Tools
- Open Terminal
- Type "clang –version"
- Follow prompts for installation
- Report mysterious errors so we can learn together
- Download Unix CLAN
- Move folder to desired install location (I used ~/Code/unix-clan)
- Edit installation files in unix-clan/src according to the instructions found in unix-clan/src/0README.TXT
- In unix-clan/src/makefile, uncomment all lines under "for Apple Unix AND FreeBSD >= 3.2"
- In unix-clan/src/common.h, update the "DEPDIR" variable: #define DEPDIR "<absolute-path-to>/unix-clan/lib" (e.g. "/Users/gilgamesh/Code/unix-clan/lib")
- Compile
- Open Terminal and cd into unix-clan/src
- type "make"
- Add unix-clan/unix/bin directory to PATH
- Create the ~/.zshrc file if it doesn't already exist
- Add the following line to .zshrc: export PATH="<absolute-path-to>/unix-clan/unix/bin:$PATH"
- Quit and restart Terminal
- Test
- cd into unix-clan/examples
- Type "freq sample.cha"
Documentation: https://jekyllrb.com
-
Install Jekyll and dependencies
gem install bundler gem install jekyll gem install jekyll-sitemap gem install jekyll-seo-tag
-
Update .bashrc and/or .zshrc
# Add Ruby Gems to path if which ruby >/dev/null && which gem >/dev/null; then PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH" fi
-
Serve web page from site directory
jekyll serve
- pages are composed of layouts and includes
- data from spreadsheet goes in data
- liquid is part of jekyll build process in github
- liquid statements can iterate through YAML files as if they are complex data structures
- content and dates pulled from workshops.yml