Readit News logoReadit News
Posted by u/baalimago 4 years ago
Ask HN: How do you sync your computer’s development configurations/environment?
I have two personal computers and one work laptop, all of which have similar development environment but not the same. One personal computer runs windows, the other two Ubuntu.

Since I knew that I will be using different IDEs and environments, I decided to learn vim and use vim bindings in all my IDEs to ensure some sort of similarity across all my development environments, but it doesn't cover it all. I've also tried manually migrating my home directory between different computers, but that comes with several issues, primarily that I'd have to try to share it between professional and personal computers. So what I'm left with is basically remembering what I'm using, and then tediously spend a day or more re-configuring newly installed computers with the software and configurations I know I'm using. It feels like I have to throw away my perfectly configured hammer which I know by heart and get a new one every time I work at a different workplace instead of bringing it along and perfecting it further. Surely there's a better way.

How do you keep your development environments/ways of working synced and backed up?

Apreche · 4 years ago
Not just with development environments, but all computer configuration, I stick with the defaults as much as possible. Instead of changing the configuration of the computer, I change myself.

For example, let's say an app has a default keyboard shortcut I don't like. I won't change it. Instead, I'll just get used to it until it becomes muscle memory.

Now the default configurations are my preferred configurations. Of course, there are still a few things I change from the defaults. But since there are so few I can just configure them by hand, because how often am I setting up a new computer? Not very often. And there are so few config changes, it only takes a minute.

The only thing I have to actually sync is my vim config. It's a very small config, but it's still more than nothing. I just store it in a Git repository.

corrral · 4 years ago
Yeah, my macOS set-up is simple enough it's not worth scripting or otherwise saving.

Use the GUI settings panel to make CAPS LOCK an extra ctrl. Takes maybe 10 seconds.

Use same to make dock auto-hide. 10 seconds if I'm slow about it.

Install Homebrew. Maybe 15 seconds hands-on and a couple minutes in the background.

Use Homebrew to install spectacle. Less than 5 seconds hands-on time, done less than a minute later.

Start Spectacle and use its preferences panel to set it to start on boot. Maybe 15 seconds.

Remove all the pinned programs on the dock. 60-90 seconds.

The last one's the only part I've considered scripting, but since I only do it once every couple years at most, it's not really worth it.

Once I'm past a Mac's initial "welcome to Mac" flow and on the actual desktop, I'm only about 5 minutes (not all of it actively doing things) from having a comfortable environment set up and being all ready to install project-specific tools, as needed.

If I ever switch back to Linux (or FreeBSD, which is more likely at this point) I might go back to versioning and backing up a bunch of config and dot files. I need them, there.

lelandfe · 4 years ago
> Use same to make dock auto-hide

Cmd-Opt-D to toggle auto-hiding – I use this one to check if the dock is frozen :)

(Also a great option to rebind: it's a global hotkey so no other app should be using it)

mickimnet · 4 years ago
Just as a sidenote, because I was using Spectacle as well. JFYI: As it is no longer maintained, I switched to Rectangle (https://github.com/rxhanson/Rectangle) and can highly recommend it.
metaltyphoon · 4 years ago
> CAPS LOCK an extra ctrl

Another fine specimen, salute!

Brajeshwar · 4 years ago
Yes, this is one of the best decision I made quite a while back. I'm usually asked for ideas and advices on how to setup computers, both technical and non-technical friends and families. I have always suggested putting a little more effort in learning the defaults and getting used to it.

I have even written a short essay, as I found myself repeating the same suggestions many a times. https://notes.oinam.com/digital/apple/

D13Fd · 4 years ago
This is where I’ve come to over the years as well. Generally defaults are best unless it’s something you really care about and that makes a big difference to your workflow.

Most configuration stuff doesn’t fit that category - or if it does, it’s best to first work on just caring about it less if possible.

Vinnl · 4 years ago
Additional benefit is that defaults are often such that they work well together, often in ways that you might not have foreseen beforehand and thus never would have set up yourself.
mekster · 4 years ago
> I stick with the defaults as much as possible. Instead of changing the configuration of the computer, I change myself.

This is the worst advice you could give. There are plenty of shitty defaults and default tastes vary from app to app and there's a reason things are customizable.

Customize to your taste throughout your tools and don't let a new tool eat your time.

__turbobrew__ · 4 years ago
You can take it even further: stick to the defaults and mainly use command line tools.

Almost every linux box has bash, vim, and the GNU command line tools. If you can become proficient with default config cli tools, you can become proficient on almost any linux box.

vlunkr · 4 years ago
I think there's a healthy middle ground here. Endless tweaking of settings tends to be a waste of time, but if you spend hours a day on a computer, you might as well make it comfortable. Some people use no $EDITOR plugins and wear it like a badge of honor, this is pretty silly to me. The few minutes it takes to install and learn about a plugin might save you hundreds on hours in the future.

I guess my personal strategy is to run with the defaults until you find the pain points, and install/configure something to address them. And put them in git repo if possible.

Sohcahtoa82 · 4 years ago
> Some people use no $EDITOR plugins and wear it like a badge of honor, this is pretty silly to me.

I don't use any plugins for PyCharm or IntelliJ, but they're pretty full-featured right out of the box. I certainly don't do it as a badge of honor, that indeed is pretty silly.

But vim is useless without any plugins. Even VSCode is only marginally better than Notepad++ unless you give it the plugins necessary to turn it into an actual IDE and not just a code editor.

Deleted Comment

hansor · 4 years ago
I'm doing the same. In some companies you can't just get ssh to outside world, or download some stuff from github... So I stick to defaults and I try to do development on single machine.
vladvasiliu · 4 years ago
I have a friend who does this. But his reasoning goes one step further. He's usually mentoring people on his team, so he finds it very valuable to be able to not only function quickly on someone else's setup, which is usually the standard, but to give them hints that'll work directly for people unfamiliar with the tools.
bananarchist · 4 years ago
This is a great answer if, like you said, you don't set up computers very often. I use mostly defaults in part because I set up computers a couple times a month. Often just for a day does that physical or virtual device live, consuming my configs, but having to manually do it every time would be a pain.
aynawn · 4 years ago
If i have to deal with ancient osx gnu gplv2 utilities, i think I'd go bananas. You have to modify the default settings at some point or your productivity will surely wane in comparison to others. I see your point with some defaults but the purest approach doesn't seem practical either.
qbasic_forever · 4 years ago
Agreed, same thing with basic stuff like color schemes. I just pick one that's auto installed by default with an IDE and stick with it. I'm tired of futzing and installing stuff to get things juuuuust right. Most IDEs come with great defaults.
sideshowb · 4 years ago
Yes, this. Custom configurations are a maintenance burden when you change systems. Living with defaults saves time in the long run, usually. Only when I spot an exception to that rule will I install something custom.
bloopernova · 4 years ago
Basically I use git for .local/dotfiles/ which are then symlinked to the relevant files like .zshrc or .emacs.d/init.el. Then I just keep that repo up to date with git pulls. Works across 2 macbooks, a Fedora workstation, and a Fedora headless server.

Couple of bits from a guide I wrote recently: https://gist.github.com/aclarknexient/0ffcb98aa262c585c49d4b...

    # store stuff here that you don't want in github
    [[ -f $HOME/.zshenv-local ]] && source $HOME/.zshenv-local

    # depends on 'brew install grep'
    [[ $OSTYPE =~ ^darwin.* ]] && alias grep='ggrep --colour=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
That OSTYPE is great for all those little bits that are unique to each operating system. The zshenv-local is in .gitignore, so you can keep tokens, api keys, etc etc in there. OSTYPE could even be used to import specific files like .zshenv-darwin or .zshenv-linux-gnu

If you're ssh'ing between your hosts, you can use something like this:

    if [[ -n $SSH_CONNECTION ]]; then
      ZSH_THEME="afowler"
    else
      ZSH_THEME="powerlevel10k/powerlevel10k"
    fi
It's not fancy and doesn't use cool tools, but my setup works for me just fine.

duffyjp · 4 years ago
I do something similar, but even simpler. I have my entire home dir as a git repo, but my .gitignore contains a single "*". I git add files I want with a -f.

I'm gonna go though your guide later though-- I like quite a bit of what I've skimmed so far. Thanks for posting that.

bloopernova · 4 years ago
Any feedback on the guide will be gratefully received. I'm trying to write better docs to give a little back to the open source community - it's not much but it's what I can manage :)

EDIT: and that "*" for gitignore is intriguing, I'll have to take a better look at that whitelist vs blacklist setup, thank you!

ScottEvtuch · 4 years ago
I've been doing "home dir is a repo" for a while now too and I'm always surprised when people think it's weird/dangerous. I wrote a few guides with tricks on how to do it on my blog that all started with "This is probably a horrible idea but here's how to do it anyway!"
glmdev · 4 years ago
I keep a .dotfiles git-repo similarly. The configs/custom scripts/etc are organized into separate folders by what they do (shell config/work tools/...) and I use GNU Stow to symlink them into my home directory. Makes setting up super easy:

    git clone <repo> .dotfiles && cd .dotfiles
    stow --target=$HOME --dir=packages shell-config
    stow --target=$HOME --dir=packages work-stuff
I've found this to be much more manageable than tools like yadm since I can pick-and-choose sets of configs/scripts based on the machine I'm using them on.

vlunkr · 4 years ago
This is what I've done for a long time. You get the benefits of keeping things synced and having a full history.
intrepidhero · 4 years ago
I did the same plus just a little bit of Ansible makes deployment a little nicer.
bloopernova · 4 years ago
I looked into Ansible after reading your comment - I've only ever used it and Puppet for larger-scale stuff so hadn't even thought of using it as a localhost-only playbook. This looks like it could manage my symlinks for me very nicely :) Thank you!
halostatue · 4 years ago
I use chezmoi (http://chezmoi.io) after years of rolling my own. It’s not as straightforward as some home managers, but the extra power it provides is _amazing_ and worth the learning curve.

I pull some information from the local keychain and others from 1Password (with `op`; I will be moving most of the rest to 1Password from the keychain). It can run additional scripts _after_ each update (I use it to update my fish plug-in installations if I change `fish_plugins`).

It has integrations with many different password managers so that it is possible truly keep your secrets out of your dotfile configuration and _still_ vary the configuration based on those secrets.

Deleted Comment

bloopernova · 4 years ago
Chezmoi looks to be exactly what I want, HUGE thank you for sharing that!
lwhsiao · 4 years ago
Another happy chezmoi user here. The templates are hugely convenient.
alexghr · 4 years ago
I use Nix to manage: - a desktop running NixOS (primary work machine) - a Macbook (secondary/travel work machine) - a Linux VM on WSL - two servers (a raspberrypi in my closet and a Hetzner vps)

I keep my config on Github (latest branch https://github.com/alexghr/nix/tree/host/vader). I'm still new to this so a lot of my config is duplicated across different hosts but I want to refactor it to eliminate duplication.

If you haven't yet, I'd recommend giving Nix/NixOS a try. There's a bit of a learning curve but it's very powerful.

notemaker · 4 years ago
It's crazy how good nixos+git gets when you've iterated for a while. I'm using the same setup on my work laptop, my home PC, and my router.

Coming up on my 1 year anniversary with NixOS and couldn't be happier, even though it has taken quite some time to adjust to (and I still barely know the language).

Having one place for all configurations is such a breath of fresh air, and having my work & home PC being identical (even Gnome is declaraticely configured!) is so nice.

Before NixOS, I resented using my private PC because it was never up to date with what I had configured on my work PC, but now that's just a "git pull && nixos-revuild switch --flake ." away - regardless of what has changed.

flurie · 4 years ago
One of the things I love the most about it is that we can use CI to update flake inputs and build configs on a cadence, which is almost like having dependabot for machine configuration.
anotherhue · 4 years ago
I've been a sysadmin since I was 12, FreeBSD, Debian, Arch, Windows (sigh). I've been an SRE managing 1k+ mixed machines. I've done nomad, k8s, docker-compose, podman, ansible, powershell admin, firecracker, gitops...

I will never, ever, use anything that doesn't behave like NixOS again. It is a sea-change.

Is the language weird? Oh yes. Is the documentation scattered? Quite. It's all worth it.

If the love of your live spoke a different native language, you'd learn it.

Stick to defaults? Hell no. Own your computing life.

oxff · 4 years ago
Nix learning curve wouldn't be bad if the documentation wasn't so bad. I have had to put together my configuration based on couple of blogposts from randoms.
JamesSwift · 4 years ago
Documentation (and cli assuming you use nix-command) today is bounds better than in the past. A huge shoutout to Jon Ringer who always seems to pop up making a positive impact whenever I google something nix-related.
rgoulter · 4 years ago
I'd say Nix is 95% wonderful, 5% very painful.

If you're trying to do something with Nix and it works, neat.

If you're trying to do something and can't get it to work, you'll have a very difficult time. (It demands a depth of understanding, and Nix is a bit weird).

Hopefully in future, "documentation", "blogposts from randoms", etc. help alleviate that pain as more people use it.

yewenjie · 4 years ago
Yup. I run one laptop and four servers on Nix. It is the only sane option I have come across so far(I used bare git repos with Arch before).
mattlondon · 4 years ago
Just use vscode and remotes. Zero hassle and zero friction - just fire up and start coding. It is seamless.

I use it on windows, Debian, macos and even Chromebooks and don't have to worry about any kind of syncing. It just works

It has a built in settings sync thing, but as a general rule I strongly strongly avoid the use custom settings (in anything) to avoid the issue you are facing. There is in my experience a huge productivity gain to be had by just being pragmatic and using (and knowing) defaults in everything you use frequently, and not being a useless prima dona if your custom key bindings are missing from every single machine you need to use each day/week/month/year. We jump around servers and computers frequently, so I find it is easiest and most productive to just go with the flow and use the defaults so I can be working immediately as soon as I SSH into a new host or am given a new laptop to use for a 3 week long contract or whatever.

davegauer · 4 years ago
Yeah, mixed environments are really tough. Though (most) of my machines are Linux, they often have _some_ stuff that should be the same and _some_ stuff that should not. My solution has been to use the fine-grained GNU Stow approach, which allows me to apply only the bits I need for a particular machine.

The files you're managing don't even need to be text, though, of course, it makes versioning, etc. a lot easier.

I also check the host name in some of the scripts to modify behavior depending on the machine.

I did a write-up about my whole setup (emphasis on GNU Stow + Git) here:

https://ratfactor.com/setup2

hummusandsushi · 4 years ago
I also use GNU Stow + Git and has worked well for me. For files I want to sync that I don't need versioning for and it is important that I have them available even in cases where I may have forgotten to commit my changes on some individual machine, I use Syncthing[1], which is really great for the more Dropbox-y kind of cross-machine sync that I also have a need for.

[1]: https://syncthing.net/

ryangibb · 4 years ago
I used to use a git repo of dotfiles which used a script to symlink into $HOME: https://github.com/RyanGibb/dotfiles

But there were a few problems with it: - installed packages needed to be managed separately (the mechanisms for which varied by platform) - managing differing configs for different machines (e.g. headless servers, hardware quirks) was done by managing different branches of this repo and rebasing, which was a pain - it was generally brittle and hard to change

I've started to use https://nixos.org/ and it's been like night and day: https://github.com/RyanGibb/nixos/

My config is version controlled, reproducible, manages packages, and is very composable.

Using the nix package manager and https://github.com/nix-community/home-manager this should work on other Linux distributions, MacOS, and even Windows Subsystem for Linux. Although I haven't tried this for myself yet.

sethd · 4 years ago
Like a few others here, I use git with a .dotfiles directory, which uses an install script that creates symblinks (among other things). It's grown a lot of over the years (maybe decade now?) and I've been meaning to look into using something like GNU Stow, but haven't got around to it.

The install script and configuration works on macOS and Linux, but sometimes requires updating when running on a new machine (like recently when provisioning a new M1 Max MacBook Pro). At one point I had it installing default packages (particularly a lot of stuff from Homebrew), but ultimately moved away from that because I realized it just kept too much old unused cruft hanging around.

I also have my configuration files setup so that it can be used for work or personal machine. For example, my .gitconfig includes another config when in the ~/work directory:

    [includeIf "gitdir:~/work/"]
      # work-specific settings (override email, etc.)
      path = ~/work/.gitconfig.inc
https://github.com/sethdeckard/dotfiles

bloopernova · 4 years ago
I'd never heard of the Include behaviour for gitconfig files. That's really nice, thank you for sharing that!