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:
- You should be able to reach them via a network
- 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: