How I set up new MacBooks(catalins.tech)
53 points by cmpit 14 days ago | 15 comments
enescakir 14 days ago
When you search for "dotfiles" on GitHub, you'll find plenty of good script examples for setting up a new computer. Since Apple doesn't provide good documentation on what you can configure with "defaults" variables, these examples are a goldmine.
cmpit 14 days ago
That's how I found some to be honest. :-)
sandreas 14 days ago
Jeff Geerling has a phenomenal ansible playbook to setup his macs:

https://github.com/geerlingguy/mac-dev-playbook

pridkett 14 days ago
I moved all my setup to Ansible about five years ago. It’s been awesome, especially as it makes it trivial to replicate changes to new machines. Installed a new package? Run the playbook again. Changed a script? Run the playbook again.

Sure, there are edge cases I hit because I have some older machines, but for the most part, it’s awesome. I’m up and running on new Macs within a coffee break of getting terminal access.

nunez 14 days ago
This is the ideal version of the playbook I've been wanting to write for years to automate the chaotic dotfile collection I've written over the last 15 years!
montroser 14 days ago
PSA: "setup" is a noun, and "set up" is the verb you're looking for.
cmpit 14 days ago
Noted, thank you!
14 days ago
rcarmo 14 days ago
I have https://github.com/rcarmo/ground-init - which I also use for Macs, although via a bit of a hack right now. I should update it to a brewfile-like setup...

Anyway, my $0.02 is that doing fully automated installs on Macs is a fast track to having weird Finder and settings bugs (if not worse), so I mostly just install packages and very seldom (if ever) apply settings via the CLI -- I've had Apple break things across too many OS releases to find that a worthwhile long-term strategy, and most of the time I'd rather just use Migration Assistant (across Macs with equivalent OS versions) or configure settings manually for a new OS release.

Edit: just went and updated the above script to support brew/cask installs on macOS. Settings can go into the runcmd section.

broshtush 14 days ago
nix-darwin is a thing, and like all nix tools. It tackles this exact problem
gbrindisi 14 days ago
I do this too. Nix is incredible, until it isn’t and then I regret using it so much.

I’ll probably use something dumber for the next machine, and keep nix for servers and local vms.

mcgrath_sh 14 days ago
I'm trying nix instead of Homebrew on my mac. It worked great until I decided to give rust a shot. I think my solution is to just do rust development on my Arch machine and stick with nix. That said, if I run into additional issues, I will probably just go back to Homebrew.

Where were your pain points?

gbrindisi 13 days ago
from the top of my head: various hacks to make apps available to spotlight, packages/apps behind their equivalents in brew to the point where I use nix to orchestrate brew for too many things, starting envs and build switch is too slow for my taste despite caching etc, nix the language is unfriendly and hard to debug, the stack traces are useless, etc
phinnaeus 14 days ago
Highly recommend keeping Nix to your NixOS machines. IYKYK
jmpz 13 days ago
Can you elaborate? I don't know, and would like to know.
14 days ago
KolenCh 13 days ago
I have custom scripts to bootstrap my macOS as many others here, and I can testify that migrating to nix-darwin greatly simplified my scripts.

P.S. I don’t use home manager though as I also need to bootstrap systems without nix.

joeyagreco 14 days ago
KolenCh 13 days ago
Interesting! Do you know how to convert com.local.KeyRemapping.plist to the JSON format you used for remapping keys?
emchammer 14 days ago
Why are macOS keyscan codes 11 digits long?
frizlab 14 days ago
Probably modifiers in the binary number, where a specific bit means something. That gives very large numbers in the end.
bombcar 14 days ago
I used to hand-setup each new Mac, but lately (last decade or so; gosh this M1 Pro is absolutely ancient) I just let the migration assistant do the needful.

Storage is too cheap for me to spend time optimizing it anymore. I’m sure I have cruft somewhere, but it doesn’t bother me.

ojhughes 14 days ago
> I just let the migration assistant do the needful

but will it revert back if things go wrong?

bombcar 14 days ago
It leaves the "source computer" alone, so if it blows up you can always just start again.

I never trade in my old computer, even if I'm going to sell or get rid of it (donate) I keep it around for a month or so to make sure everything's working.

phinnaeus 14 days ago
It reverts back and it does it at its earliest.
timothevs 14 days ago
Dear, this was gold.
cmpit 14 days ago
I get that. Personally, I'm a bit weird because I don't like to bring all the stuff from the previous machine (documents, files, etc.). I like to start fresh and only install a couple of apps / configure some settings.
bombcar 14 days ago
Understandable - it gives you a chance to do "spring cleaning" and decide what you really want/use.
cmpit 14 days ago
Exactly, haha. If something's important enough, it'll find its way to the new machine. :-D
kartikarti 14 days ago
Just in case anyone is lost in all the `defaults write ...`, I really recommend https://macos-defaults.com/

It's a really nice overview for (almost) all of the options.

frizlab 14 days ago
I have an open-source script which installs all my conf https://github.com/Frizlab/frizlabs-conf
cmpit 14 days ago
Thanks for sharing it. Will deffo have a look and pick some stuff for my config.
moribvndvs 14 days ago
I use a setup script that installs brew, a brewfile, runs chezmoi to setup terminal and defaults, pulls some secrets/keys out of 1Password, and good to go, other than manually having to log into certain things. Everything in a personal dotfiles repo. I do have to occasionally diff my brewfile and terminal config and push that up, I should probably spend a little time figuring out how to automate that.
1inuxoid 14 days ago
I am also using this setup powered by chezmoi. It has brilliant secrets support and powerful templating allowing cross-platform setups. I do get lost in its state sometimes when updating `run_once_*` scripts and trying to make sure they still run. Another friction point is external tools installed via .chezmoiexternal.toml from GitHub.
nunez 14 days ago
same, more or less!
corv 14 days ago
The missing magic incantation to create your Brewfile:

brew bundle dump

pss314 13 days ago
In the case of an existing Brewfile, make sure to execute "brew bundle dump --force" to overwrite the Brewfile with updated list of formulae, kegs etc.
bitslayer 14 days ago
Ah ha! I had searched the article to see if there was a way to do that. Because while it would be awesome to have a file like this, creating it sounded like a pain.
bhouston 14 days ago
Thank you!
iorekz 14 days ago
sweeeet
bhouston 14 days ago
Is there any shell/bash extensions that just allow you to use LLMs easily from the command line? Basically like warp but just a simple extension instead of a full iterm replacement?
dankobgd 14 days ago
Just use Ansible, it's the best for installing and configuring things
mcgrath_sh 14 days ago
Professionally? Sure. Personally, I don't want to learn and maintain ansible for something I do once every 5-7 years. I basically diffed the defaults and got the settings I need to change in my script. I then add or remove them as I tweak things (infrequently). The rest of my shell script is a Makefile I use cross platform for making directories and stow-ing dotfiles.
frizlab 14 days ago
No. I tried, the person from which I initially based my conf repo[1] tried too[2], we both went away from it (w/o communication between us). We both realized Ansible is good for managing many machines in a professional environment, but waaaay overkill to manage the configuration of a single machine (or two or three), as well as incredibly obtuse in its syntax.

[1] <https://github.com/Frizlab/frizlabs-conf> [2] <https://github.com/wincent/wincent>

bhouston 14 days ago
I think the lessons in this article are still great and you can automate them via ansible. E.g. install brew, run brewfile, apply default config, etc.
nunez 14 days ago
slow solution if you want to configure your box quickly and idempotently whenever you launch a terminal (IMO).
ghusto 14 days ago
I'm always a little upset when I read posts excited about configuring things, where they've missed the obvious tooling that's designed for it. Not sure why, but it makes me sad.
blame-troi 14 days ago
Obvious to whom? We don’t all know everything. Also, rolling your own can be an interesting learning exercise.
14 days ago