This repository contains my nix configurations (for nixOS, macOS, linux and wsl). Nix home-manager is used across all systems to manage my dotfiles and user specific applications. Nix darwin is used to manage my macOS machines.
-
Install Nix:
sh <(curl -L https://nixos.org/nix/install)
-
Clone repo and create a custom config
Clone this repository to your home directory:
cd ~/.config && git clone https://github.com/CemDK/nix.git && cd nix
In the
flake.nix
file add your hostname and username to thedarwinConfigurations
attribute set. For example, if your username isCoolGuyUser
and your hostname is2010-Macbook
, you would add:darwinConfigurations = { "CoolGuyUser@2010-macbook" = mkDarwinConfig { system = "x86_64-darwin"; # or "aarch64-darwin" for M1/M2/M3/M4 Macs user = "CoolGuyUser"; host = "2010-macbook"; userHost = "CoolGuyUser@2010-macbook"; home = "/Users/CoolGuyUser"; }; # ... other macOS configurations };
Create a new file:
/users/CoolGuyUser/home.nix
{ pkgs, user, home, ... }: # A minimal config might look like this: { # Import modules that you want to use # default.nix is my own bespoke custom made artisinal handcrafted setup # so beware that it already contains my configuration for zsh, tmux, zoxide, etc. imports = [ ../../modules/home-manager/default.nix ]; home = { username = user; homeDirectory = home; }; # You can manage dotfiles here home.file = { }; # Add packages that are specific to this user here home.packages = with pkgs; [ neovim go ]; }
-
Run nix-darwin Rebuild:
Finally, to install nix-darwin and apply your configuration, run the following command:
sudo nix run nix-darwin/master#darwin-rebuild -- switch --flake ~/.config/nix/.#$(whoami)@$(hostname -I)
Afterwards, if you include the aliases from my zsh config, you can run these aliased commands
nixup
,nixswitch
andnixclean
or the defaultsudo darwin-rebuild switch --flake ~/.config/nix/.#$(whoami)@$(hostname -I)
.