5 ms·
I would love to get to a point where my laptop can be managed as immutable infrastructure. All the big chunks of data are already isolated into redundant parti
by jedberg 7y ago
I would love to get to a point where my laptop can be managed as immutable infrastructure.
All the big chunks of data are already isolated into redundant partitions, but it’s the system config that’s tough.
I have a time machine backup, but that’s still not the same as being able to say “I’m gonna wipe my hard drive and start over today”.
So does anyone have have good suggestions on maintaining a MacOS laptop in an immutable way?
- dirtydroog 7y agoWell, going by the functional programming crowd's take on immutability, you just have to buy a new laptop each time.
- gav 7y agoI'd love to get to make further inroads, but I treat my MacBook as something that's disposable, there's nothing on it that I care about. - Pretty much all my software comes from brew or brew cask - All my files are stored in either DropBox or Google Drive (split is for legacy reasons mostly) - All my work is in a remote Git repository - My local config is also in Git Anything else isn't backed up. I treat ~/Documents as scratch. It's not ideal because it still takes some time to configure and log on to a bunch of cloud services, but maybe it says something about moving into management that I spent 90% of my day inside of Firefox, Mail, and Slack...
- gowld 7y agoBut do you have a way to migrate to new hardware when the time comes?
- gav 7y agoBasically grabbing a saved Brewfile[1], running `brew bundle install` and waiting a while. [1]https://github.com/Homebrew/homebrew-bundle https://github.com/Homebrew/homebrew-bundle
- jedberg 7y agoDo you know of an easy way to create a brew bundle from already installed applications?
- the_alchemist 7y agoIn the readme it's mentioned. brew bundle dump https://github.com/Homebrew/homebrew-bundle/blob/master/README.md#dump https://github.com/Homebrew/homebrew-bundle/blob/master/READ...
- jedberg 7y agoThanks. Totally missed that. Edit: Huh, only 90 packages. I was expecting more!
- ChristianBundy 7y agoFun trivia: the original implementation[0] was 17 lines of Ruby, which was absolutely terrible because I didn't know what I was doing. I'm happy to see that it's grown so much! [0]: https://github.com/Homebrew/legacy-homebrew/pull/24107 https://github.com/Homebrew/legacy-homebrew/pull/24107
- gav 7y agoProjects are often like stone soup, it takes somebody to kick the process off, and I thank you for that. I saw that it now supports Whalebrew[1], which seems interesting. One of the issues that I have with Brew is that often my need is temporary and that I want to be able to clean up afterwards (similar to `git stash`). [1] https://github.com/whalebrew/whalebrew https://github.com/whalebrew/whalebrew
- zimbatm 7y agoIn the same vein as TA, nix-darwin[1] can be used to configure macOS applications and services. It's not exactly the same as NixOS because the whole system is not entirely managed by Nix but it gets you closer. There is also Ansible, Chef, Puppet, ... but in my experience the overhead to write and test those config files is even hired than using Nix. [1]: https://github.com/LnL7/nix-darwin https://github.com/LnL7/nix-darwin
- jkachmar 7y agoIn practice you can actually get extremely close to having Nix manage your whole macOS system with the exception of actual OS-level updates (and particular tools like Xcode, I suppose). John Wiegley’s system configuration [0] is an example of this, although it is extremely ambitious and definitely not a good place to start for anyone who has used Nix before. One of the interesting things that Wiegley does for further reproducibility is to have Nix manage and install DMG-based Applications [1] in addition to CLI apps, services, and other system-level things. [0] https://github.com/jwiegley/nix-config https://github.com/jwiegley/nix-config [1] https://github.com/jwiegley/nix-config/blob/bbad310daa1106f6ccff08292b7dfb9b574584f4/overlays/30-apps.nix#L25 https://github.com/jwiegley/nix-config/blob/bbad310daa1106f6...
- j88439h84 7y agoYou can run nix and home-manager on mac.
- joshspankit 7y agoIn the world of commercial software that’s essentially impossible. Any immutable infrastructure lights up license keys and demo restrictions like a spotlight. Take, for example, Apple’s desktop OS: You used to be able to drag-drop an application to install it. To uninstall you would delete it. Simple. Easy. Stateless. They talked about it a lot and so did Mac evangelizers. But it also meant you could walk in to an Apple store, connect a USB drive in your sleeve to a demo computer, drag, drop, and walk away with full versions of very expensive software. So, the OS fell prey to the same stateful pitfalls as Windows: places to hide keys, system hooks, etc, etc, etc. Your best bet these days is likely to manage all software config through a system management tool, keep your data backed up in Time Machine, and “reprovision” your laptop every X days or months.
- jedberg 7y ago> Your best bet these days is likely to manage all software config through a system management tool, Got any good examples? This is usually where I get stuck and can't find a good solution that works well with MacOS.
- mason55 7y agonix + home-manager will get you pretty good coverage for non-commercial software. The learning curve is steep but once you get there it's amazing.
- joshspankit 7y agoI can’t remember the particulars right now, but there’s a small team that remotely manages the macbooks of Google employees. I suspect that their tools would be a great fit here.
- lstamour 7y agoThey started using Puppet against Mac dev machines, then switched to internal tools I believe. But it was one of the first times it occurred to me that we should manage and use DevOps and SRE practices against user machines and user workloads where possible. The trouble is the tooling isn’t that mature yet, and we can’t assume real-time data or always connected machines, and we don’t have a herd because users only have one machine with them at any time and remote state deletion only works when you know you’re not deleting critical state, which in turn requires better tooling and a greater understanding of user application state persistence behaviour than most are willing to invest time in doing. This is what makes Chromebooks so easy to maintain though: web apps and sandboxed Android apps can all easily sync to the cloud and compartmentalize their data.
- memco 7y agoI experimented with a version of this: https://github.com/mathiasbynens/dotfiles https://github.com/mathiasbynens/dotfiles. It worked ok. Still had a few things I had to tweak, but if you have a few things you want to keep it's easy. I basically only use a brewfile + a shell script to set a few defaults and some configs for iterm + kitty that I keep in my personal repo. Makes the most repetitive bits a lot easier. The MAS homebrew stuff didn't work too well when I migrated machines so I still had to install some stuff by hand.
- jimbokun 7y agoI find iOS devices get surprisingly close to this. If you have iCloud backups, do a final sync, then restore to the device you just bought. This has been the process for the last several iPhones I've bought for my family. At the Apple Store, they walk you through this process so everything is set up before you leave. It's hard to tell the difference between your old and new device, in terms of software and data, for the most part.
- jedberg 7y agoThe iPhone is amazing in this regard. I've upgraded multiple phones this way, and it's almost flawless.
- deleted 7y ago[deleted]
- joshspankit 7y agoI would temper this slightly as I’ve actually had cases where cruft also follows from one device to another. It’s much better now than it used to be, but there are still time where I have to sacrifice data by uninstalling/reinstalling or resetting settings. Top of my wishlist for iOS is Apple letting us manage (and potentially fix) our backup data.
- deleted 7y ago[deleted]
- asdf-asdf-asdf 7y agoyou can use NixOS on MacOS. i was planning to try it out (currently i use homebrew), but with Catalina it seems things are somewhat complicated for nixos+macos. my understanding is that NixOS wants to live in "/nix", and Catalina does not like that. there are some solutions to this problem but they seem somewhat incomplete (you have to make an unencrypted partition for Nix etc..), though i haven't tried it so i might be wrong :) https://github.com/NixOS/nix/issues/2925 https://github.com/NixOS/nix/issues/2925 https://github.com/NixOS/nix/pull/3212 https://github.com/NixOS/nix/pull/3212
- bcrosby95 7y agoI don't know if it's usable for a MacOS laptop, but I use Ansible for my various Linux dev machines, and if you handed me a fresh install, once I got my Ansible directory onto the laptop I could get it completely up and running with a single command.
- abathur 7y agoI'm not as far along this curve with macOS as Graham is with NixOS (and I'm a little jealous), but I'm approaching something like what you ask for. Feel free to ask questions; I'll try to remember to check back. I have an air from 2013; I moved (regrettably, given the keyboard) to a new air around this time last year and used the process as an excuse to force myself to specify everything well enough that I could recover everything I need from stock macOS from a short bootstrap script. I use yadm (~git) for my dotfiles, Nix for everything Nix can do readily, brew bundle for a few mac apps around the edges, and 3 small restic backups for some project files and such. My dotfiles contain a longer bootstrap script that takes over the heavy lifting once yadm is installed. This script configures most of the settings I need on the way, and prompts me to do the few bits I haven't found a good way to automate. It also collapses ~/Downloads, ~/Desktop, and ~/Documents into a single directory, so that I don't have out-of-sight/mind places for state to hide. It has been a lot of work, but it has bought me peace-of-mind that I can replace my system quickly (i.e., be ready to work on a new device in ~2h with maybe 20 minutes of actual babysitting?) That said, I think the basics here are actually fairly low-hanging fruit. You can also make some really quick progress once you know you've got everything essential safeguarded if you're willing to take a dive like Graham has here and let minor losses roll off your back. Access to a second mac also helps a lot; iterating on problems in the actual bootstrap process is slow, and best done while you have a working system you can stay productive on. I'm currently most of the way through building out the rough inverse of my bootstrap script--a script that audits as much of my "state" as it can; I hope to have it working for a living as part of my backup runs soon. It cleans up and auto-commits anything it can, tells me what is in a clean state, reassures me not to worry about everything I've worried about during past moves, and gives me an explicit checklist for anything that isn't buttoned up. I think the main things left are forcing me to deal with downloads/desktop/documents as I go (with measures like Graham's being on the table...), and figuring out if there's a sane way to audit for drift in my macOS system/app settings.
- jedberg 7y agoThanks for the details. When you set up a new system, how do you solve for these: All my Firefox plugins and their config (I guess this is technically data) All the settings I've changed though the control panel (I can't figure out every file that changes when I make a change). Any time I've changed a setting with nvram or defaults Most of the settings of the default apple apps. My wireless configs This is always the part I get stuck on.