macOS can run nix, using nix-darwin!
First install nix with the DeterminateSystems installer, instructions are in their [readme](https://github.com/DeterminateSystems/nix-installer).
A lot of packages in nix aren't quite ready for macOS, so fallback to brew. Install from [brew.sh](https://brew.sh/).
> Note: Where you see "kahoo", is where you must put your short hostname. You can see what your short hostname is by running `hostname -s`.
Then make a nix flake with a starter config: (just make a folder with these two files in it)
flake.nix:
```nix
{
description = "nixconf";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ nixpkgs, home-manager, darwin, ... }: {
darwinConfigurations."kahoo" = darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
./configuration.nix
];
};
};
}
```
configuration.nix:
```nix
{ pkgs, ... }:
{
nixpkgs.hostPlatform = "aarch64-darwin";
users.users.mark.home = "/Users/mark";
fonts = {
fontDir.enable = true;
fonts = with pkgs; [
nerdfonts
vazir-fonts
vazir-code-font
];
};
environment = {
shells = with pkgs; [
bashInteractive
zsh
];
loginShell = pkgs.zsh;
systemPath = [
"/opt/homebrew/bin"
"/Users/mark/.rd/bin"
"/Users/mark/.docker/bin"
];
};
services = {
nix-daemon.enable = true;
tailscale.enable = true;
};
programs = {
zsh.enable = true;
};
homebrew = {
enable = true;
caskArgs.no_quarantine = true;
global.brewfile = true;
casks = [
"docker"
"google-chrome"
"obsidian"
"orbstack"
"rancher"
"raycast"
"visual-studio-code"
"warp"
];
taps = [];
brews = [
"lima"
];
};
}
```
To activate the new config, run:
```sh
$ darwin-rebuild switch --flake '/Users/mark/nixconf#'
```
To update the nix package set, run:
```sh
$ nix flake update '/Users/mark/nixconf#'
```
## Further configuration
You can find a list of all the options and relevant documentation [here](https://daiderd.com/nix-darwin/manual/index.html).
You can configure more things like editors and stuff using [home-manager](https://github.com/nix-community/home-manager).
(home-manager is amazing!)
The home-manager options can be browsed [here](https://mipmip.github.io/home-manager-option-search/).