Keep your development environment deterministic and instantly rebuildable.
You should ideally be able to take your hard drive out, put in a new one, install a fresh OS, run 1 script, and be completely up and running in less than an hour.
As an added bonus, this means that you can replicate your development environment on any machine very quickly and easily, which makes losing your laptop during travel only an inconvenience rather than a travesty.
I've hacked together some scripts for that here [1], although I really should convert them to ansible or something.
I've always agreed in principal, but fell short in practice until I started using Nix[1]. Nix makes it significantly easier to pull off by verifying the hashes of all inputs, eliminating non-determinism in builds (timestamps, usernames, etc), eliminating dependencies on OS packages/files/etc, and allowing you to pin to a specific snapshot of all packages. Pardon the evangelism, I'm just a happy user.
I like to combine Nix with direnv (and direnv-mode for Emacs - there are also similar plugins for most other editors).
Then you can `cd` into your directory and your environment appears.
The downsides are that there is a steep and long learning curve, and that your colleagues will not understand what you've done.
I also use NixOps to actually deploy my code at the moment, but I will probably be switching to Terraform shortly as I need some tools like AWS autoscaling groups, which NixOps doesn't support.
I agree. It's a game changer when you can easily replicate all or specific parts of your dev setup with one command, everywhere (remote server, new laptop, dev vm, even containers).
I wrote a script for this too (actually using Ansible), but then everything got a bit out of hand and now it's a framework (as those things go): https://freckles.io
If I may ask, what was the reason for moving away from Ansible and resorting to building something yourself? What kind of issues did you encounter that Ansible couldn't solve?
Oh, sorry, I didn't express myself clearly: freckles still uses Ansible under the hood, it's just that the whole project sort of went it's own way and dragged me with it. Feels like it, anyway :-)
freckles actually supports multiple backends, but Ansible is the only one that is implemented currently. I chose that mainly to take advantage of
all the modules and roles out there, those can all be used from within freckles.
As to it's disadvantages: for some things Ansible is a bit heavy (needs to be installed, and Python available/installed on the target), or not as well suited (orchestration -- although I'm quite happy with what it can do in that space), so the plan is to have other backends (shell, Terraform, direct K8s, etc) that are a better fit for whichever context you are operating in. And of course you will be able to mix and match.
Anyway, if I could have only picked one backend, I'd still go with Ansible. It's a great platform, and it can do almost everything.
I’ve had to rebuild my machine at work twice and some people look at you like you told them your dog died. We never had it automated but we did have it written down.
One of those, we got a bad batch of laptops. Over a summer five of us had to go through the same thing. The only rough part was the whole disk encryption. That took longer than the rest combined.
"You should ideally be able to take your hard drive out, put in a new one, install a fresh OS, run 1 script, and be completely up and running in less than an hour."
this is great if you can pull it off but if you have a lot of disjointed systems plus maybe custom hardware it gets really hard to automate the process. In general I agree though. I also have learned to just live with the defaults of my IDE(s) instead of setting them up to my taste every time.
I keep all my Emacs config files in a git repository, so I can quickly pull it wherever I happen to be using Emacs. Might be practical for some IDEs too depending on their configuration file formats. I'd imagine it would work fine if the configuration is stored as XML.
Keep your development environment deterministic and instantly rebuildable.
You should ideally be able to take your hard drive out, put in a new one, install a fresh OS, run 1 script, and be completely up and running in less than an hour.
As an added bonus, this means that you can replicate your development environment on any machine very quickly and easily, which makes losing your laptop during travel only an inconvenience rather than a travesty.
I've hacked together some scripts for that here [1], although I really should convert them to ansible or something.
[1] https://github.com/kstenerud/virtual-builders
https://github.com/kstenerud/ubuntu-dev-installer