Skip to main content

One File to Rule Them All: Reclaiming Your Dev Environment with Nix and Home Manager

·398 words·2 mins·
Srini
Author
Srini

TL;DR:
Does your organization’s onboarding involve a long checklist of installation and configuration steps?
Do you spend time recreating your prompt on every new machine?
Do you struggle to remember what apps you installed but never touch?
Are you lost in a sea of .dotfiles and can’t recall why half your shell aliases exist?
I was — until I started managing everything with Nix and Home Manager on WSL2. Now, I declaratively version my full dev setup — tools, shell, configs, and more — from one file.


🧙 Why Bother?
#

Modern dev life involves juggling too much:

  • Custom shell prompts you forget to port
  • Brew/NPM/PIP installs scattered across time
  • .dotfiles repo that’s half magic, half mystery

The result? You waste hours getting “back to normal” after switching machines or reinstalling Linux.

💡 Enter: Nix + Home Manager
#

With Nix, your packages are declared in a single config file.
With Home Manager, your dotfiles and shell setup live in the same config.
Combined, they make your environment:

  • Reproducible — clone and go
  • Declarative — no more remembering obscure install flags
  • Portable — use the same setup across Linux, macOS, and WSL2

🏗 My Setup
#

I run this on WSL2 with Ubuntu, and let Home Manager handle:

  • Fish shell with prompt themes
  • Git config and aliases
  • Tmux, Neovim, fzf, bat, zoxide — all auto-installed
  • Custom environment variables

Here’s a snippet from my home.nix:

programs.fish.enable = true;
programs.git = {
  enable = true;
  userName = "Srini";
  userEmail = "srini@example.com";
};
programs.zoxide.enable = true;
programs.bat.enable = true;
programs.tmux = {
  enable = true;
  extraConfig = "set -g mouse on";
};

🧪 Bootstrapping a New Machine
#

Clone your dotfiles and run:

nix run home-manager/master – switch –flake ~/.dotfiles And that’s it — you’re home.

🧼 Bonus: Fewer Ghost Settings
#

Every config change is version-controlled. I can see:

  • When I added an alias

  • Why I disabled a plugin

  • Which tool update broke my workflow

No more wondering “what broke my prompt?” after a mysterious update.

🪄 Tips
#

How do I cache my ssh passphrase using Nix home-manager?
#

   initExtra = ''
      # Enable caching of ssh passphrase
      keychain -q --nogui $HOME/.ssh/id_ed25519

      source $HOME/.keychain/$HOSTNAME-sh
    '';

🧾 Final Thoughts
#

If you’re an engineer who hates repetition (and let’s face it — who doesn’t?), this setup is worth trying. It’s not magic, but it feels like it.