Clone your dotfiles repository to the desired location on your system:
git clone git@github.com:yeonhwan/dotfiles.git ~/dotfiles
# if you have not set up SSH keys, use HTTPS
git clone https://github.com/LnL7/nix-darwin.git ~/dotfilesFollow the Nix installation process as described on the official website: https://nixos.org/download/.
Alternatively, you can use the following command:
sh <(curl -L https://nixos.org/nix/install)Build and apply the nix-darwin configuration using your flake.nix:
# you should enable nix flake and nix-command first
mkdir -p ~/.config/nix && echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
# this is the default flake for all environments (not plan to support multiple environments yet)
nix run nix-darwin -- switch --impure --flake ~/.dotfiles/nix/.config/nix#defaultUse GNU Stow to link your dotfiles to their appropriate locations in the home directory:
-
To stow all configurations at once:
cd ~/dotfiles stow .
-
To stow specific configurations (e.g., Neovim and Nix only):
stow nvim nix
After completing the steps, verify the setup:
-
Check the Nix installation:
nix --version
-
Verify that
nix-darwinis installed and functioning:darwin-rebuild --version
-
Confirm that GNU Stow has correctly applied the dotfiles by inspecting your home directory.
-
Using
darwin-rebuildInstead ofnix run: After the initialnix-darwinsetup, you can use the following command to rebuild and apply configuration changes: Note : --impure flag is needed to access system enviornment variablesdarwin-rebuild switch --impure --flake ~/.dotfiles/nix # can use shell alias after building the flake buildflake
-
Homebrew is not installed:
if the nix-darwin doesn't install homebrew, you can install it manually by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Preview Stow Changes: Before applying
stow, preview the changes to avoid overwriting existing files:stow --no . -
SSH Key Issues with Git: Ensure your SSH keys are properly set up for GitHub. Test them with:
ssh -T git@github.com
-
If you encounter Brew package error with Application.app:
Delete the Application.app from the /Applications directory and reinstall the package with brew.
-
Commands:
# Update packages and rebuild the flake (brew packages are updated when rebuilding is done) nix flake update # Garbage Collecting sudo nix-collect-garbage -d # Rollback to certain version # switch to certain commit and rebuild the system
-
If xCode is not installed
xcode-select --install