Welcome to my personal dotfiles and system configuration repository! This setup uses Nix for package management and system configuration (on macOS via Nix-Darwin), and GNU Stow for managing symbolic links of dotfiles.
- A non-root user with
sudoprivileges. - Internet connection.
- Git (This will be installed if missing on macOS, instructions provided for Linux).
- (macOS only) You might be prompted to install Xcode Command Line Tools if
gitis not found, usingxcode-select --install.
Please follow the steps relevant to your operating system.
If you don't have Nix installed, open your terminal and run the following command. This uses the Determinate Systems Nix Installer, which is a recommended installer.
curl --proto '=https' --tlsv1.2 -fsSL https://install.determinate.systems/nix | sh -s -- installAfter installation, you MUST open a new terminal window or source the Nix profile script for the nix command to be available:
# Run this in your current terminal, or simply open a new one
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.shVerify Nix installation:
nix --versionChoose a location for these configuration files. A common choice is ~/dotfiles.
# Ensure git is installed
# On Debian/Ubuntu: sudo apt update && sudo apt install git
# On Fedora: sudo dnf install git
# On Arch Linux: sudo pacman -S git
# On macOS: Xcode Command Line Tools (usually prompted if git is missing) should provide it.
git clone https://github.com/iarchean/dotfiles.git ~/dotfiles # Replace with your repo URL if different
cd ~/dotfilesNix-Darwin will be used to configure your macOS system declaratively and install system-wide packages, including GNU Stow (assuming it's defined in the flake).
-
Build and Apply the Nix-Darwin Configuration: This command will read the
flake.nixin this repository, build your system configuration, and then switch your system to use it. This process can take a while, especially on the first run.# Ensure you are in the dotfiles directory (e.g., ~/dotfiles) # cd ~/dotfiles/nix # This command builds the configuration and then applies it. # It might ask for your sudo password during the 'switch' phase. nix build .#darwinConfigurations.mac.system && ./result/sw/bin/darwin-rebuild switch --flake .#mac
If you encounter permission issues with
nix build, ensure your user has a correctly configured Nix environment. Runningdarwin-rebuildtypically handles its ownsudoneeds. -
Link Your Dotfiles with GNU Stow: After
darwin-rebuild switchcompletes successfully,stow(and other packages defined in your flake) should be installed and available in yourPATH.- Open a new terminal window to ensure all environment changes are loaded.
- Navigate to your dotfiles directory:
cd ~/dotfiles
- Use
stowto create symbolic links for your configuration files. For example, to link configurations fornvim,fish, andtmux(assuming you have directories namednvim,fish,tmuxin~/dotfiles):stow nvim fish tmux
- To link all packages (subdirectories) in your dotfiles directory:
(Note:
stow */stow .would try to stow files in the current directory as well,stow */focuses on subdirectories which is common for Stow packages). Adjust based on your Stow setup.
-
(Optional) Restart: Some system-level changes applied by Nix-Darwin might require a logout/login or a full restart to take full effect.
On Linux, Nix will be used as a package manager to provide tools like stow and your preferred applications. Your system itself is not managed by Nix in this setup.
-
Ensure Nix Environment is Active: If you haven't already, open a new terminal or run:
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh -
Install GNU Stow (and other tools) using Nix: Navigate to your dotfiles directory (
cd ~/dotfiles). You have a few options:- Install
stowto your user profile (recommended for general availability):nix profile install nixpkgs#stow
- (Optional) Install a pre-defined set of tools from this flake (if available):
This flake might expose a package set (e.g., named
tools-linux). Check theflake.nixoutputs.# From within ~/dotfiles nix profile install .#tools-linux # Replace 'tools-linux' if your flake uses a different name
- (Alternative) Use a Nix development shell:
This provides the tools only within the activated shell session.
You'll need to be in this shell to use
# From within ~/dotfiles nix develop .#env-linux # Replace 'env-linux' if your flake uses a different name
stowif you choose this method.
- Install
-
Link Your Dotfiles with GNU Stow: Once
stowis available (either from your Nix profile or within anix developshell):- Navigate to your dotfiles directory:
cd ~/dotfiles
- Use
stowto create symbolic links. For example:stow nvim fish tmux
- Or, to link all packages (subdirectories):
stow */
- Navigate to your dotfiles directory:
-
macOS: To update your system after making changes to the Nix configuration in this repository:
cd ~/dotfiles git pull # Get latest changes if you version control your flake nix flake update # Optional: update flake inputs like nixpkgs nix build .#darwinConfigurations.mac.system && ./result/sw/bin/darwin-rebuild switch --flake .#mac
-
Linux:
- To update tools installed via
nix profile install: You might need to update your flake inputs (nix flake updatein~/dotfiles) and then re-run thenix profile install .#tools-linuxcommand or update individual packages (e.g.,nix profile upgrade stow). - If using
nix develop, exiting and re-entering the shell after agit pullandnix flake updatewill usually pick up changes.
- To update tools installed via
command not found: nix: Ensure you've opened a new terminal after installing Nix or sourced the profile script:. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh.command not found: stow:- macOS: Ensure
stowis listed inenvironment.systemPackagesin your Nix-Darwin configuration anddarwin-rebuild switchcompleted successfully. Open a new terminal. - Linux: Make sure you've installed
stowvianix profile install nixpkgs#stow(and opened a new terminal) or are inside anix developshell where it's provided.
- macOS: Ensure
- Stow conflicts (
existing target is not a symlinkorwill not overwrite existing file): This means Stow found an existing file or directory where it wants to create a symlink. You may need to manually back up and remove these conflicting files/directories from your home directory before runningstow. For example, if~/.config/nvimexists and is not a symlink, Stow won't overwrite it unless you use options like--adopt(use with caution) or remove it first.
curl -fsSL https://raw.githubusercontent.com/iarchean/dotfiles/main/scripts/init.sh | sudo sh
reference:
- https://github.com/omerxx/dotfiles
- https://zero-to-nix.com
- https://sandstorm.de/blog/posts/my-first-steps-with-nix-on-mac-osx-as-homebrew-replacement/
- https://xeiaso.net/blog/nix-flakes-1-2022-02-21/
- https://blog.6nok.org/how-i-use-nix-on-macos/
- https://nixcademy.com/cheatsheet/
- https://nixcademy.com/posts/nix-on-macos/
- https://github.com/ironicbadger/nix-config/blob/main/justfile
[TODO] nvim and tmux pane switch plugin tmux shortcut to switch pane show vim status in tmux status bar