Personal dotfiles using Nix for reproducible system/package management and GNU Stow for dotfile symlinking.
Initial installation
[!IMPORTANT]
Make sure your terminal has full disk access on macOS before installing.
# Clone repo
git clone https://github.com/fredrikaverpil/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
# Install Nix (Determinate Systems installer - enables flakes by default, better uninstall,
# survives macOS updates, consistent installation across Linux/macOS)
# Choose "Determinate Nix" when prompted (performance optimized, better error messages)
# Learn more: https://determinate.systems/nix
# IMPORTANT: choose "no" during install, so to install upstream Nix.
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
# Set hostname to match a configuration in nix/hosts/
# macOS: sudo scutil --set HostName <hostname>
# Linux: sudo hostnamectl set-hostname <hostname>
# Apply configuration
# Linux (NixOS):
sudo nixos-rebuild switch --flake ~/.dotfiles#$(hostname)
# macOS (first time only):
sudo nix --extra-experimental-features "nix-command flakes" run nix-darwin -- switch --flake ~/.dotfiles#$(hostname)
# After first-time setup, use the rebuild script:
./rebuild.sh
# Rebuild system + packages + dotfiles
./rebuild.sh
# Update flake inputs (nixpkgs, home-manager, etc.) then rebuild + dotfiles
./rebuild.sh --update
# Dotfiles only (no Nix rebuild)
./rebuild.sh --stow
Troubleshooting
# Update all unstable/Darwin-related inputs (dev machines)
nix flake lock \
--update-input nixpkgs-unstable \
--update-input home-manager-unstable \
--update-input nix-darwin \
--update-input dotfiles
# Update all stable/Linux-related inputs (prod servers)
nix flake lock \
--update-input nixpkgs \
--update-input home-manager \
--update-input nixos-raspberrypi \
--update-input disko \
--update-input dotfiles
If you get errors about com.apple.universalaccess
or system settings during
nix-darwin activation:
- Grant Full Disk Access to your terminal:
- Open System Settings > Privacy & Security > Full Disk Access
- Click + and add your terminal app (e.g.,
/Applications/Utilities/Terminal.app
) - Enable the checkbox for your terminal
If you get SSL certificate errors after switching from Determinate to upstream Nix:
# Fix broken certificate symlink
sudo rm /etc/ssl/certs/ca-certificates.crt
sudo ln -s /etc/ssl/cert.pem /etc/ssl/certs/ca-certificates.crt
# Clean up leftover Determinate configuration
sudo cp /etc/nix/nix.conf /etc/nix/nix.conf.backup
sudo tee /etc/nix/nix.conf << 'EOF'
extra-experimental-features = nix-command flakes
max-jobs = auto
ssl-cert-file = /etc/ssl/cert.pem
EOF
# Check configuration
nix flake check ~/.dotfiles
# Verbose rebuild
sudo nixos-rebuild switch --flake ~/.dotfiles --show-trace # Linux
darwin-rebuild switch --flake ~/.dotfiles --show-trace # macOS
# Clean cache
nix-collect-garbage -d
# Rollback
sudo nixos-rebuild --rollback # Linux
darwin-rebuild --rollback # macOS
Repo structure
βββ nix/ # Nix configurations
β βββ hosts/ # Host-specific configurations
β β βββ $host/ # Individual host directory
β β βββ configuration.nix # System settings
β β βββ hardware.nix # Hardware config (optional, for NixOS)
β β βββ users/
β β βββ $username.nix # User config
β βββ lib/ # Helper functions
β β βββ default.nix # Library entry point
β β βββ systems.nix # System configuration helpers
β β βββ users.nix # User configuration helpers
β βββ shared/ # Shared configurations
β βββ home/
β β βββ common.nix # Cross-platform user packages
β β βββ darwin.nix # macOS user config
β β βββ linux.nix # Linux user config
β βββ overlays/
β β βββ default.nix # Overlay entry point
β β βββ neovim.nix # Neovim overlay
β βββ system/
β βββ common.nix # Cross-platform system packages
β βββ darwin.nix # macOS system config + Homebrew
β βββ linux.nix # Linux system config
βββ nvim-fredrik/ # Neovim configuration
βββ shell/ # Shell configuration
β βββ bin/ # Custom shell scripts
β βββ aliases.sh # Shell aliases
β βββ exports.sh # Environment variables
β βββ sourcing.sh # Shell sourcing logic
βββ stow/ # GNU Stow dotfiles
βββ extras/ # One-off platform-specific extras and legacy configs
βββ flake.nix # Nix flake configuration
βββ rebuild.sh # Main rebuild script
Component | Tool | Scope | Configuration Location |
---|---|---|---|
User dotfiles | GNU Stow | Per-user | stow/ |
User packages | home-manager | Per-user | nix/shared/home/ |
User preferences | home-manager | Per-user | nix/shared/home/ + host-specific |
Host configuration | nix-darwin/NixOS | System-wide | nix/hosts/*/configuration.nix |
System packages | nix-darwin/NixOS | System-wide | nix/shared/system/ |
System settings | nix-darwin/NixOS | System-wide | nix/shared/system/ |
Homebrew packages | nix-darwin | System-wide | nix/shared/system/darwin.nix |
Package overlays | Nix | System-wide | nix/shared/overlays/ |
- NixOS configuration options: stable | unstable
- Home manager configuration options
- nix-darwin configuration options
Package Type | macOS System | macOS User | Linux System | Linux User |
---|---|---|---|---|
CLI tools | Nix | Nix | Nix | Nix |
GUI apps | Homebrew | Homebrew | Nix | Nix |
Mac App Store apps | Homebrew | Homebrew | - | - |
Fonts | Nix | Nix | Nix | Nix |
The intent here is to follow "unstable" sources on development machines, but remain "stable" on e.g. production servers.
Component | macOS Source | Linux Source | Rationale |
---|---|---|---|
nixpkgs | nixpkgs-unstable | nixpkgs (25.05) | macOS: latest, Linux: stable |
home-manager | home-manager-unstable | release-25.05 | macOS: latest, Linux: stable |
nix-darwin | master (uses unstable) | - | Always latest features |
Registry shortcuts:
# Stable packages
nix shell n#neovim
# Unstable packages
nix shell u#nodejs_22
Dotfiles are managed with GNU Stow, not Nix:
- Edit files in
stow/
directory - Changes are immediately active (no rebuild needed)
- Nix runs stow commands during home-manager activation
# Manual stow (if needed)
cd ~/.dotfiles/stow
stow --target="$HOME" --restow shared "$(uname -s)"
- rpi5-homelab - requires custom installation procedure