Skip to content

Latest commit

 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotfiles

Nix-managed macOS dotfiles using nix-darwin, nix-homebrew, and home-manager.

Installation

# 1. Install Nix
sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install)

# 2. Open a new terminal and confirm Nix is available
nix --version

# 3. Clone dotfiles
nix-shell -p git --run "git clone https://github.com/shoyoshikane/dotfiles ~/dotfiles"

# 4. Back up existing system shell configs if nix-darwin reports conflicts
sudo mv /etc/bashrc /etc/bashrc.before-nix-darwin
sudo mv /etc/zshrc /etc/zshrc.before-nix-darwin

# 5. Apply the host profile for the first time
host="<host>"
sudo -H /nix/var/nix/profiles/default/bin/nix run \
  --extra-experimental-features nix-command \
  --extra-experimental-features flakes \
  github:nix-darwin/nix-darwin/master#darwin-rebuild -- \
  switch --flake "$HOME/dotfiles/.config/nix#$host"

After the initial setup, use the flake apps:

darwin-switch
darwin-build
darwin-check
darwin-update

Layout

  • .config/nix/flake.nix: entrypoint
  • .config/nix/hosts/gift/default.nix: host profile
  • .config/nix/modules/host-spec.nix: shared host metadata options
  • .config/nix/darwin/aerospace.nix: AeroSpace service
  • .config/nix/darwin/borders.nix: JankyBorders service
  • .config/nix/darwin/homebrew.nix: Homebrew formulae and casks
  • .config/nix/home-manager/dotfiles.nix: symlinks for dotfiles
  • .config/nix/home-manager/packages.nix: user CLI packages

Adding A Host

Create a new host profile from an existing one:

host="<host>"
cp -R "$HOME/dotfiles/.config/nix/hosts/gift" \
  "$HOME/dotfiles/.config/nix/hosts/$host"

Then update .config/nix/hosts/<host>/default.nix:

{
  hostSpec = {
    username = "<username>";
    hostName = "<host>";
  };

  system.stateVersion = 5;
}

Finally, add the host to .config/nix/flake.nix:

hosts = {
  gift = ./hosts/gift;
  <host> = ./hosts/<host>;
};

Notes

  • Existing dotfiles are backed up with the .backup suffix when home-manager first takes over.
  • Existing Homebrew installations are migrated by nix-homebrew; undeclared packages are not removed because Homebrew cleanup is disabled.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages