My name is Bryce. I build software. This website is a collection of my personal projects and writings.
subscribe via Atom
fully nix-pilled
Published on 2024-06-21 —

I recently bought a new MacBook, and instead of manually installing everything for the nth time, I decided to go down the path of using Nix and nix-darwin to codify my dev machine configuration. If you're curious, let's dive in.

What is Nix?

Nix is a few things which I would break down into three categories:

  1. A configuration and build system referred to as "Nix".
  2. A configuration language, confusingly also referred to as "Nix".
  3. A package manager wherein the official packages are referred to as "nixpkgs".

First and foremost, Nix is a configuration system for describing declaratively how your system should be configured. This includes things like packages, applications, and shell configuration, but can even include OS settings like your preferred scroll direction (natural scrolling disabled of course, for the sophisticated among us). If you've ever used something like Terraform or CloudFormation to set up your infrastructure, then in this context you might think of Nix as being like Terraform for your personal machine. When you "build" a version of your system configuration, Nix produces a "generation", which conceptually can be thought of as a deterministic snapshot of your system given the current configuration.

Second, the name "Nix" is also used (confusingly) to refer to the underlying configuration language itself that the configuration files are written in. This language is a declarative scripting language which is used to configure your system. In my experience it was relatively easy to get started with. The documentation is great, and there are a number of existing examples to work from.

Finally, Nix is a package manager. It has an official repository of packages called "nixpkgs" which you can browse here. When you define your configuration, you'll likely specify packages which will be sourced from nixpkgs. For example, things like git, or zsh, or python.

What is nix-darwin?

As my personal computer is running macOS, I am also using nix-darwin, which is a set of modules specifically for configuring macOS. It allows you (among other things) to modify operating system settings like the dock, hot corners, dark mode, etc. Not every single item within "System Settings" is supported yet, but it gets you most of the way there.

Conclusion

Ok, so that's a high-level overview of Nix, but why bother with any of that? For myself, I'd break it down as follows:

Pros

Cons

Using Nix for my dev machine has been working great for me so far, and I'm now fully nix-pilled. You can check out my configuration here.

We could go deeper down the rabbit hole and talk in more detail about how Nix works under the hood. Or we could speak to more of the Nix ecosystem like home-manager, flakes, or NixOS; but I'll stop here for now. 🙃