Cross-platform dotfiles supporting both macOS and Linux using Nix flakes, nix-darwin, and home-manager.
git clone https://github.com/elgertam/dotfiles ~/.dotfiles
cd ~/.dotfiles
chmod u+x *.sh
./reload.shgit clone https://github.com/elgertam/dotfiles ~/.dotfiles
cd ~/.dotfiles
# Edit hosts/linux-desktop.nix for your hardware
sudo nixos-rebuild switch --flake .#linux-desktop# Install Nix first
curl -L https://nixos.org/nix/install | sh
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
# Install Home Manager
nix run home-manager/master -- init --switch
# Clone and apply dotfiles
git clone https://github.com/elgertam/dotfiles ~/.dotfiles
home-manager switch --flake ~/.dotfiles#ameThis configuration provides:
- Package Management: Homebrew casks for GUI apps
- System Settings: macOS defaults (dock, finder, etc.)
- Window Management: Hammerspoon for automation
- Container Runtime: Podman with launchd services
- Package Management: Native Nix packages + Flatpak
- Desktop Environment: GNOME (default), KDE, or i3
- System Settings: GNOME/desktop environment defaults
- Container Runtime: Podman with systemd services
- Shell: Zsh with Oh My Zsh
- Development Tools: Git, Vim, direnv, nix-index
- Language Support: Node.js, Python environments
- Cross-platform aliases and environment variables
├── flake.nix # Main entry point
├── hosts/
│ ├── shared.nix # macOS shared config
│ ├── linux-shared.nix # Linux shared config
│ ├── linux-desktop.nix # Example Linux host
│ ├── laforge.nix # macOS hosts
│ ├── spock.nix
│ └── riker.nix
├── modules/
│ ├── core/ # Core Nix configuration
│ ├── roles/ # User roles (developer, personal, etc.)
│ ├── system/
│ │ ├── darwin-defaults.nix # macOS system settings
│ │ ├── gnome-defaults.nix # Linux/GNOME settings
│ │ ├── homebrew.nix # macOS package management
│ │ └── linux-packages.nix # Linux package management
│ ├── podman-darwin.nix # macOS container services
│ └── podman-linux.nix # Linux container services
├── users/ame/ # User-specific configuration
└── rc/ # Configuration files
├── hammerspoon/ # macOS window management
└── vim/ # Editor configuration
# Apply configuration changes
~/.dotfiles/reload.sh
# Update package sources
~/.dotfiles/update.sh# Apply configuration changes
sudo nixos-rebuild switch --flake ~/.dotfiles#your-hostname
# Update and rebuild
sudo nixos-rebuild switch --upgrade --flake ~/.dotfiles#your-hostname# Apply user configuration changes
home-manager switch --flake ~/.dotfiles#ame
# Update packages
nix flake update ~/.dotfiles
home-manager switch --flake ~/.dotfiles#ameEdit hosts/linux-desktop.nix to choose your desktop environment:
# GNOME (default)
services.xserver.desktopManager.gnome.enable = true;
# KDE Plasma
services.xserver.desktopManager.plasma5.enable = true;
# i3 Window Manager
services.xserver.windowManager.i3.enable = true;Uncomment appropriate drivers in your Linux host configuration:
# NVIDIA
services.xserver.videoDrivers = [ "nvidia" ];
# AMD
services.xserver.videoDrivers = [ "amdgpu" ];- Copy
hosts/linux-desktop.nixtohosts/your-hostname.nix - Run
nixos-generate-configand copy hardware configuration - Customize bootloader and system settings
- Add to
flake.nixnixosConfigurations - Build with:
sudo nixos-rebuild switch --flake .#your-hostname
- macOS: 72 Homebrew casks for GUI applications
- Linux: Native Nix packages + Flatpak for additional apps
- macOS: Darwin defaults control dock, finder, trackpad, etc.
- Linux: Desktop environment settings (GNOME/KDE) or window manager configs
- macOS: Hammerspoon for advanced automation and window control
- Linux: Native window managers (i3, GNOME Shell, KDE) with extensions
- macOS: Podman machine with launchd services
- Linux: Native Podman with systemd services
- Aliases:
pbcopy/pbpaste→xclipequivalents on Linux - Paths:
/Users/ame→/home/ame, different socket locations - Commands: Platform-specific variations (e.g.,
ls -Gvsls --color=auto)
You may encounter errors about existing files. Follow the included instructions and retry - Nix's reproducible builds minimize system damage risk.
Missing Packages: Some macOS apps lack direct Linux equivalents. Check modules/system/linux-packages.nix for alternatives.
Hardware Problems: Run nixos-generate-config to generate proper hardware configuration.
Graphics Issues: Ensure correct drivers are enabled in your host configuration.
Container Problems: Linux uses systemd instead of launchd. Use systemctl commands.
macOS/Linux: Run /nix/nix-installer uninstall. You may need to restore these files:
/etc/zshrc
/etc/bashrc
/etc/zshenvMove vimrc & tmux.conf into the flake
- Zero to Nix https://zero-to-nix.com
- Nix Pills https://nixos.org/guides/nix-pills/
- Intro to the Nix language, derivations and nixpkgs (video) https://www.youtube.com/watch?v=9DJtHIpdp0Y
- home-manager options https://nix-community.github.io/home-manager/options.html
- nix-darwin options https://daiderd.com/nix-darwin/manual/index.html#sec-options
Inspired by https://github.com/ameske/.dot_files