QQ - I have a working installation of home-manager and the nixos hardware repo via a flake.
In the past I would reinstall from the ISO (GUI), clone down my repo, swap out the disk info, and then run something like sudo nixos-rebuild switch --flake .#host-name
Is there a better way to do this? I do have a little helper script that does the disk swap, but I suspect I am missing something, and there might be a better way to do this. My gut feeling is that it is like using the ISO, manually partitioning and passing the flake in with some nix-install type command.
I am just looking for a way to do as little as possible on a new system setup. I even keep flip-flopping on how to encrypt secrets in a way that I have to do as little as possible on a new system. (ie git-crypt vs sops vs the other options). Efficiency, laziness, call it what you like. (I prefer not to partition if I do not have to manually. haha).
nixos-install will automatically enable the experimental features for the issued nix commands when --flake is passed, smilar to how nixos-rebuild does.
One of the major problems of nixos-install --flake is, that it still leaks the hosts store paths to the target system somehow, which then causes errors like this:
“Hard link from /nix/store/… to /mnt/nix/store/… not possible as its different devices” (paraphrased).
It is still recommended for most usecases to do a quick installtion with a minimal generated configuration that will ensure that internet is available after the installation and then after having booted into the system, just use nixos-rebuild --flake to do the actual thing…
You could netboot and determine by Mac or other hardware properties which host it is and run automatically Disko and the nixos install. Probably only worth it for servers and if you have many.
It sounds like doing the rebuild post install is more the norm than I thought.
In my current method I had bootstrap script that would extract my disk info, replace it in my files from my repo and rebuild. I might just stick with that.
Or I could try and figure out how to reference by labels (so I wouldn’t need to modify the disk info). In theory anyways.
Or investigate the disko method. But it sounds like it’s overkill.