Minimal, performance-focused configuration using Nix. Extremely snappy without sacrificing convenience.
My dotfiles are optimized for Linux, but since
they are POSIX compliant, they should work on macOS or BSD as well (as long as
the necessary packages are available).
Please feel free to copy bits and pieces that you like ;)
Repository layout:
flake.nix: entrypointhosts/: one per machine, each host sets hostname, username, and imports the modules it needs.base/: shared baselinemodules/composable modules that hosts can mix and match:cli: shared command-line tools and development packagesgui: graphical apps and desktop settings for non-headless machinesdotfiles: configuration for nvim, tmux, zsh, fzf, sway, and more!personal: personal-machine configurationwork: work-specific packages and configuration
- Modules follow this pattern:
default.nix: entrypoint (Nix convention)darwin.nix: Darwin overridelinux.nix: Linux override
Fork this repo, then:
- Add a new host to
hosts/${HOSTNAME}.nix(or update an existing one) to match your machine and it toflake.nix - Customize the host's composable modules
- Set your username and hostname
- Replace the SSH public keys and dotfiles repository URLs (if you don't want to use my dotfiles)
- Replace any host-specific hardware settings
- Follow installation and usage instruction below
- Customize the rest of the repo for your needs and clean up things that you don't use
Review the base, hosts, and modules directories and adjust the configuration to match your machines before installing.
Boot into the NixOS live ISO, then install the tools needed for the initial bootstrap:
nix-shell -p git gnumake neovim diskoClone the repository and run the installer:
git clone https://github.com/khuedoan/nix-setup
cd nix-setup
make install host=HOSTNAME disk=/dev/DISKReplace HOSTNAME with the host module you want to install and /dev/DISK with
the target disk device.
Before the first run:
- Update the hostname and
primaryUser.usernamevalues inhosts/ - Go to
Settings > Privacy & Security > Full Disk Accessand allow Terminal
Clone the repository and apply the configuration:
git clone https://github.com/khuedoan/nix-setup
cd nix-setup
make switch host=HOSTNAMEReplace HOSTNAME with the matching entry in flake.nix. The rebuild script
installs Nix and Homebrew automatically on a fresh macOS system if they are not
already present.
Then reboot.
Diff the new configuration against the current system profile:
make diffApply changes on an installed machine:
make switchUpdate packages:
make updateBuild a specific host without switching:
make build host=HOSTNAMEClean up Nix store:
make cleanGitHub Actions builds all NixOS and Darwin hosts, then applies the test hosts.
You can also test this locally in VMs:
NixOS:
make test
macOS:
- Install UTM
- Download macOS IPSW recovery file
- Create a macOS VM in UTM using the downloaded IPSW file
- Run
xcode-select --installin the new VM - (Optional) Clone the VM to a new one for easy rollback (UTM doesn't support snapshot yet)
- Follow the above steps
I always try to lazy load where possible. This section attempts to demonstrate how snappy it is.
- Last updated: December 7, 2023
- Hardware: Ryzen 5 5600X, 32GB of RAM, running NixOS 23.11
Opening Zsh:
time zsh -i -c exit (47ms)
zsh -i -c exit 0.04s user 0.01s system 100% cpu 0.047 total
Opening the terminal (including waiting for the shell):
time foot zsh -i -c exit (67ms)
foot zsh -i -c exit 0.05s user 0.02s system 103% cpu 0.067 total
Opening Neovim with 14 plugins:
time nvim --headless +qa (47ms)
nvim --headless +qa 0.03s user 0.01s system 83% cpu 0.047 total
- LunarVim/LunarVim Neovim config
- LunarVim/nvim-basic-ide Neovim config
- siduck76/NvChad Neovim config
- nvim-lua/kickstart.nvim config
- mattydebie/bitwarden-rofi script
- LazyVim/LazyVim config and lazy loading
- Vim statusline without a plugin
- Microphone tuning guide by Paul W. Frields, EasyEffects preset by MateusRodCosta and the modified version by jtrv
- Swap two containers in Sway
- How core Git developers configure Git
- The Git Commands I Run Before Reading Any Code
- Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
