Perfect sync between two devices?

I know you can copy your config, and run flake updates and rebuilds when you need to use another device, but has anyone made anything or thought about how to achieve near perfect sync between two devices? I am talking about all the home desktop files, when an update runs on one system, an update also runs on the other, you can add exceptions e.g driver differences but has anyone ever tried to make it so you can have as much parity as possible between two devices? e.g laptop and desktop. So you can switch between them effortlessly, NixOS probably takes you most of the way there, but there is still some other things which needs to be done for this.

You could probably use a fleet management or GitOps style solution, that can push from a central server, or pull updates from a centralized (git) repo.

Like at least one of these can do one or the other.

Use flakes or the new system.nix mechanism to have individual entrypoints per system which also load all the shared modules you have.

This is a solved problem for many years, even though the system.nix thing is rather new, more tedious solutions have been available already when I started using NixOS nearly 7 years ago.

I think a lot of people are already doing this (including me). When you install NixOS, the configuration.nix (and hardware-configuration.nix) is under /etc/nix.
But actually, it doesn’t have to be there, you can have it on your own git repository. And you can start adding as many hosts as you want, and apply the configuration to remote NixOS machines.

Let’s say you want to have the same configuration in 2 different machines, you could have something like this folder structure:

nix-config
β”œβ”€β”€ flake.nix  # or the new system.nix
β”œβ”€β”€ shared-configuration.nix 
β”œβ”€β”€ hosts
β”‚   β”œβ”€β”€ delta
β”‚   β”‚   └── configuration.nix # imports  the dell hw & shared
β”‚   └── epsilon
β”‚       └── configuration.nix # imports the lenovo hw & shared
└── hw
    β”œβ”€β”€ dell-x
    β”‚   └── hardware-configuration.nix
    └── lenovo-s
        └── hardware-configuration.nix

And just using regular tools built into NixOS, you can update the derivations on both machines:

nixos-rebuild switch --flake ".#delta"  # this would be the machine you are using
nixos-rebuild switch --flake ".#epsilon" --target-host epsilon # this would be the remote machine

To update remote machines:

  1. You should be able to reach them via a network
  2. The remote machine should allow an SSH key on the the machine you are running the switch from to access it.

And the good thing is that once you start hitting certain limitations, you’ll discover the community has already hit those limitations and you’ll find new tools.

This is my config for example: