dotfiles for macOS machines with nix
This is a set of dotfiles and installation scripts appropriate for machines running macOS using nix and home-manager.
A small caveat: these files are useful to me, i.e. @dmentipl; they might also be useful to you.
There are two main requirements:
- Nix; see https://nixos.org/guides/install-nix.html.
- Home-manager; see https://github.com/nix-community/home-manager#installation.
Note: if the nix command is not on the path run the following.
. ~/.nix-profile/etc/profile.d/nix.sh
After installation, home-manager will ensure nix is properly configured.
-
Clone this repository locally (or download a tarball/zip archive) to
~/repos/dotfiles
-
Symlink
home.nix
to~/.config/nixpkgs
:ln -s ~/repos/dotfiles/home.nix ~/.config/nixpkgs/home.nix
-
Run home-manager:
home-manager switch
Each time you make a configuration change in home.nix
or its dependencies do the following.
home-manager switch
To update all nix packages do the following.
nix-channel --update
# NOTE: this may take a while
home-manager switch
This is analogous to sudo apt upgrade
.
Nix and home-manager manage the installation of command-line applications such as: bat
, dust
, exa
, fd
, fish
, fzf
, htop
, jq
, neovim
, pandoc
, procs
, ripgrep
, sd
, tmux
, and trash
. See home.nix
and files imported therein for further details.
Nix and home-manager also manages the configuration of those applications, including via symlinking of dotfiles to the appropriate locations in $HOME
. This includes dotfiles such as config.fish
, git/config
, init.lua
, settings.json
, starship.toml
, and tmux.conf
, for example.
The following applications are not managed by nix or home-manager.
- marp to generate slides from markdown. Download the stand-alone binary from the GitHub releases page and put in
~/bin
. - pandiff for producing file diffs for any files that pandoc supports. Install with
node -g install pandiff
into an appropriate node installation. - starship for a configurable command prompt. Download the stand-alone binary from the GitHub releases page and put in
~/bin
. - vale styles. Download styles and put in
~/.config/vale/styles
. The VSCodium extension expects.vale.ini
in the working directory, so symlink as follows:ln -s ~/.config/vale .vale
. See errata-ai/styles for a list of styles. - watchexec to watch for file changes then execute a program. Download the stand-alone binary from the GitHub releases page and put in
~/bin
.
The following extensions are not managed by nix or home-manager.
-
codium extensions. Install with the following
for ext in $(jq '.recommendations[]' -r base/editors/extensions.json) do codium --install-extension $ext done
See
base/editors/extensions.json
for the list of "recommended" extensions. -
neovim extensions. First, install paq (a package manager) with the following
git clone --depth=1 https://github.com/savq/paq-nvim.git \ "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/paqs/start/paq-nvim
Then run
:PaqInstall
inside Neovim. Seebase/editors/init.lua
for the list of extensions. -
Doom Emacs configuration for Emacs.
git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.emacs.d ~/.emacs.d/bin/doom install
To install the Xcode command line tools (which include git and other basic programs) run:
xcode-select --install
Generate a public-private key with the following.
ssh-keygen -t ed25519 -C "your_email@example.com"
Start the ssh-agent in the background.
eval "$(ssh-agent -s)"
The following goes in ~/.ssh/config
.
Host *
IgnoreUnknown UseKeychain
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
Add the key to the ssh-agent.
ssh-add -K ~/.ssh/id_ed25519
Then you can add the public key to, for example, GitHub via the web interface.
Configure macOS, e.g. Finder, the Dock, trackpad and keyboard, terminal. See mac.sh
for details.
base/os/mac.sh
Note: it seems that many settings cannot be scripted.
- System Preferences -> Security & Privacy -> General
- Tick
Require password
and set to"Immediately"
- Go to System Preferences -> Keyboard -> Modifier Keys...
- Set
Caps Lock Key
to"No Action"
- System Preferences -> Displays -> Night Shift...
- Set
Schedule
to"Sunset to Sunrise"
Install the following applications manually.
- Brave
- Emacs
- iTerm
- Logseq
- Obsidian
- Signal
- Spotify
- Transmission
- VSCodium
Install the following utilities manually.
- KeepingYouAwake
- ProtonVPN
- Sync
I like Fira Code font. Install manually from here.