/nixos-config

A NixOS flake for my macOS development environment

Primary LanguageNixMIT LicenseMIT

Squirmy's NixOS Config

A NixOS Flake for my macOS development environment.

I have tried to keep this as simple as possible.I only have one machine and the simpler this configuration is the more likely I am to be able to maintain and keep this up to date.

There are many comments throughout the files helping to explain why lines of configuration exist. I'm going to need this later when I forget just exactly why I put that line there.

My introduction to NixOS was through the following resources:

Combined, they proved a handy resource for working out where I was going wrong, and how I might improve this setup. They also introduced me to some new tools which I'll be trialling instead of my previous setup.

One thing is for sure, creating your own flake is personal, as each of the above configurations were differently structured. This configuration is no different.

Getting Started

Install pre-requisites:

  1. NixOs (Multi-user installation)
  2. Homebrew

Clone this repository:

mkdir -p "$HOME/.config"
git clone https://github.com/squirmy/nixos-config "$HOME/.config/nixos-config"

Run the ./go.sh script:

⚠️ Warning: Are you me? If not, stop and read I'm not squirmy.

cd "$HOME/.config/nixos-config"
./go.sh

Installing on a fresh macOS installation

I plan to run this on a fresh setup from time to time so I have created an install script to automate the above tasks. It can be tweaked for your own setup. Please be careful using this and take the time to understand how it works before you run it.

Steps:

  1. Sign in with your Apple ID
  2. Enable FileVault
  3. Restart
  4. Run the install script
bash <(curl -L 'https://raw.githubusercontent.com/squirmy/nixos-config/main/install.sh')

I'm Not Squirmy

There are some things you need to be aware of before you run this on your system.

  1. There are system defaults configured in configuration/nix-darwin/macos.nix that will persist even after installation. Double check that you're ok with these settings, and if not remove or customize them.
  2. You need to customize your user details in flake.nix. Be sure to set your username, name and e-mail.
  3. You need to customize your hostname in flake.nix. The relevant config is nix-machine.macos.{your-hostname-here}. Run hostname -s to get the correct value.
  4. Update the DNS resolvers in configuration/nix-darwin/network.nix if you prefer another resolver.
  5. Read through the rest of the files carefully and decide if you want the configuration. Remove anything you do not want to be included. You can always add things back in.

Known Issues

1. Could not write domain: com.apple.Safari.

This can be fixed by giving your terminal full disk access in Settings -> Privacy & Security -> Full Disk Access.

Fix found on reddit.

Safari is sandboxed preventing defaults from read/writing to it. Your terminal needs full disk access so defaults can access the sandboxed container.

Valuable Resources

Nix Darwin

Home Manager