Modern dotfiles configuration that documents and sets up my optimal development setup for MacOS and Linux (with specific focus on immutable distros such as Fedora Atomic series and SteamOS).
The main rationale behind moving to a Nix-based approach:
- Increased efficiency: Integrated configuration management and application installation
- Dependency isolation: Less software version conflicts and pollution of global install.
- Easier customization: Popular tools are automatically set up close to our preferences.
- Development shells: No need to pollute global packages, setup tailored development "containers"
Nix will be used to automate the installation and configuration of command-line tools. UI-extensive applications such as terminal emulators, browsers, etc. will be installed via either Homebrew Casks (MacOS), Flatpak (Fedora et al), or Snaps (Ubuntu).
- Set a hostname for the machine using System Settings and via the following command:
sudo scutil --set HostName <HOSTNAME>
- Enable FileVault and reboot the machine
- Install Homebrew
- For Nix installer, we recommend using the Determinate Systems Nix installer with default Nix flakes support and a MacOS updates survival mode. For instructions on using the official Nix installer, see Appendix A
- Install Nerd Fonts -- at the minimum, JetBrainsMono Nerd Font
- Install B612 Font and Questrial
- Make sure Flatpak is installed and Flathub is added as a repository. Follow instructions here for setting up Flathub with Flatpak.
- Install the following Flatpak packages either through UI or via Flatpak command line interface:
com.github.tchx84.Flatseal
org.mozilla.firefox
- GhosTTY (pending Flakpak for now as per Jan 2025)
- For platforms without
make
installed, runnix-shell -p gnumake
to enter a Nix shell withgnumake
installed.
- Install Nix: the package manager and restart the shell
- Enable flakes support by creating
~/.config/nix/nix.conf
with the following contents:experimental-features = nix-command flakes
mkdir -p ~/.config/nix echo experimental-features = nix-command flakes > ~/.config/nix/nix.conf
- Checkout dotfiles repository:
git clone https://github.com/andermatt64/dotfiles
- In a terminal, change the current directory into the repository root,
dotfiles
- Run
make
-- this should verify all the prerequisites are in place and runnix run path:$(pwd) -- switch --flake path:$(pwd)
.
Note: We do not add
fish
to/etc/shells
nor set it as the default shell for the main user anymore. This is so that we have an emergency shell to quickly fall back on in the event that a MacOS update breaks Nix store.
- Start a new shell and run
make casks
to install Homebrew Casks. - Consider manually installing Questrial font
- In System Settings:
- Add Amethyst explicitly as a Login Item in System Settings
- Unselect Automatically rearrange Spaces based on most recent use under Mission Control panel in Desktop & Dock
- Ensure Switch to Desktop <N> is enabled and mapped to Alt-<N> under Mission Control in Keyboard Shortcuts
- Set Delay until repeat to one notch to the left of Short in Keyboard
- Set Key repeat rate to the notch under Fast in Keyboard
- Set Natural scrolling to ON in Mouse
- In the Shortcuts tab pane under Amethyst Settings, clear the following shortcuts:
- Move focus to main window
- Move focus to counter clockwise screen
- Move focus to clockwise screen
- Swap focused window to counter clockwise screen
- Swap focused window to clockwise screen
- Swap focused window with main window
- Focus screen <N>
- Throw focused window to screen <N>
- Toggle focus follows mouse
- Toggle global tiling
- Select Tall layout
- Select Wide layout
- Select Column layout
- The Flatpak package for the desired terminal emulator may require additional permissions in order to read configuration files. To fix, open Flatseal and make sure the terminal emulator has the ability to read from
/nix/store
and~/.nix-profile
.
This setup uses different language configurations from default Helix Editor. Below is a list of the different configurations and what language server (LSP) and formatters are required.
Language | LSP | Formatter |
---|---|---|
Python | basedpyright | ruff |
HTML | Default | prettier |
JSON | Default | prettier |
CSS | Default | prettier |
JavaScript | Default | prettier |
TypeScript | Default | prettier |
TSX | Default | prettier |
Install and set the default toolchain to be stable:
rustup default stable
Install rust-analyzer:
rustup component add rust-analyzer
Update packages by running the following command:
make update
Occasionally, Nix store grows quite large because of orphaned packages. Use
make gc
to clean up.
In the event a MacOS update breaks Nix store, the following steps should alleviate most issues:
Make sure /etc/zshrc
ends with the following stanza:
# Nix if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' fi # End Nix
Make sure /etc/synthetic.conf
contains the content: nix
- Single-user installation mode has not been tested and may not be supported. A different script may be required to run at startup for single-user mode.