Kicking off an installation - existing config files

Hey there!

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. :rofl: (I prefer not to partition if I do not have to manually. haha).

1 Like

The nixos-install tool seems to take a --flake option. So, perhaps it is just to boot the ISO, mount the disks under /mnt and then run

$ export NIX_CONFIG="experimental-features = nix-command flakes" # Maybe?
$ nixos-install --flake "$REPO_FLAKE_URL#$HOSTNAME"

Just a guess, though, I have never tried this but hopefully it gives you a place to start.

1 Like

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…

1 Like

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.


Thanks everyone!

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.

I appreciate the help!

edit or build a custom iso.