A Nix-based dotfiles repository using a two-layer approach:
- GNU Stow manages shell-managed dotfile symlinks (
.zshrc,.vimrc, etc.). - Nix flakes (Home Manager and nix-darwin) manage declarative packages and user configuration.
Hosts are defined in common/.config/home-manager/hosts.tsv using this format:
config_name|system|username|home_directory|aliases|display_name|primary_user|darwin_extra_modules
The current host is auto-detected via scutil --get ComputerName (macOS) or hostname -s (Linux). You can override the active host with the HOME_MANAGER_CONFIG environment variable.
Run this on a fresh machine. It handles everything:
./install.shThis script:
- Installs bootstrap packages (
git,curl,zsh) if needed - Calls
scripts/bootstrap-install.zshwhich:- Installs Nix via Determinate Installer
- Links dotfiles via dotsync (stow-based)
- Installs Homebrew on macOS (admin required)
- Configures macOS defaults
- Installs nix-darwin on macOS (admin required)
- Optionally applies Home Manager on Linux (
USE_HOME_MANAGER=1)
If you want more control or Nix is already installed:
# 1. Clone the repo (if not already)
git clone <repo-url> ~/.dotfiles
cd ~/.dotfiles
# 2. Link dotfiles (stow-based)
./scripts/install-dotfiles.sh
# or equivalently:
./common/.local/bin/dotsyncOn Linux, apply Home Manager after Nix is installed:
# Auto-detect the matching host config
./scripts/apply-home-manager.sh
# Or specify a config name explicitly
./scripts/apply-home-manager.sh somnambulistYou can override the host with HOME_MANAGER_CONFIG:
HOME_MANAGER_CONFIG=roci ./scripts/apply-home-manager.shThe maintain alias is the primary daily maintenance command. It updates all managed software and dotfiles in one step. Its behavior differs by OS:
macOS (admin):
# git pull + submodule update + dotsync + nix-darwin update + brew upgrade
maintainmacOS (non-admin):
# git pull + submodule update + dotsync
maintainLinux (admin):
# apt update + upgrade + autoremove + autoclean
maintainNote: maintain requires admin privileges on macOS to invoke make -C ~/.config/nix-darwin update.
nix-darwin manages both system state and Home Manager user state. The repo root flake is the source of truth.
Rebuild from the repo root:
darwin-rebuild switch --flake path:$HOME/.dotfiles#TheArkUpdate nix-darwin's flake inputs:
cd nix-darwin/.config/nix-darwin
make update
# or manually:
darwin-flake-updateOn Linux, the root flake's homeConfigurations apply directly:
nix run home-manager/release-25.05 -- \
switch --flake path:$HOME/.dotfiles#somnambulistOr use the helper:
./scripts/apply-home-manager.shnix flake updateThe common/.local/bin/dotsync script (alias: install-dotfiles.sh) manages dotfile symlinks via GNU Stow:
# Link all active packages (common + OS-specific)
dotsync
# Unlink all managed symlinks
dotsync --unlinkOn macOS, it stows common/, macos/, and nix-darwin/ (admin required).
On Linux, it stows common/ and linux/.
The ~/.stowrc file sets the default target to $HOME and ignores .stowrc itself plus .DS_Store.
Add or modify hosts in common/.config/home-manager/hosts.tsv. The first column (config_name) is used as the Home Manager/nix-darwin flake input name. Aliases in the aliases column are also resolved.
The home-manager-host.sh helper resolves active host information:
# Get the detected host config name
scripts/home-manager-host.sh current-config
# Get the detected host name
scripts/home-manager-host.sh current-name
# Resolve a config name from an alias
scripts/home-manager-host.sh resolve-config roci
# Look up the system architecture for a host
scripts/home-manager-host.sh lookup-system rociThere is no robust uninstaller. This removes broken symlinks from your home directory:
./uninstall.zshFor a complete uninstall, manually:
- Run
./uninstall.zshto remove dotfile symlinks - Run
nix-uninstallto remove Nix - Run
rm -rf /opt/homebrewon macOS to remove Homebrew - Remove
~/.nix-profile,~/.nix-defexpr,~/.config/nix - Remove
~/.home-manager-modules
| File | Purpose |
|---|---|
common/.config/home-manager/home.nix |
Common Home Manager modules |
common/.config/home-manager/hosts.tsv |
Host definitions |
common/.config/zsh/ |
Zsh environment, plugins, themes |
common/.config/nvim/ |
Neovim configuration |
common/.config/git/ |
Git configuration |
common/.config/ghostty/ |
Terminal emulator |
nix-darwin/.config/nix-darwin/flake.nix |
nix-darwin per-host configuration |
flake.nix |
Root flake (packages, Home Manager, host routing) |