Bluetooth Keyboard in Stage 1

What do you mean with reinstall?

If shut down the system, boot into the nixos installer and run nixos-install that won’t affect any state on your disk. Of course, if you format the disk, copy your configuration and do nixos-reinstall you will have your system but lost all state: impermanence or not, NixOS is not magic, yet.

I’m not going to format my disk, but rather delete all BTRFS volumes other than /persistent and /boot where the configuration stored.
After that I hope I’ll be able to tweak Nix to reinstall using the impermanence configuration and the data, without extra restoration steps.

The interesting thing about impermanence setups is that NixOS will already “reinstall” itself every time the computer reboots :slight_smile: That’s kind of the point of NixOS - all files on the filesystem that aren’t data should be regenerated on boot.

Hence why some in the community might not consider it a “reinstall” unless the disk is completely wiped, at which point you need a backup process in place for the persistent btrfs volumes (which you should anyway even on non-NixOS hosts).

1 Like

Right, this is the second part of the puzzle.
Some distros have cloud-init support in the installer to address this,
and as I couldn’t find a clear answer if Nix supports this, I added to the issue:
https://github.com/NixOS/nixpkgs/issues/39076#issuecomment-1921437795

It’s turned out the bluetooth keys are needed not only on the installed system, but on the installer itself, too.
As /var/ is tmpfs there, how would I add the keys to .nix configuration, to generate the proper installer .ISO image?

To be clear, you’re trying to make the (let’s say) bluetooth keyboard work in the NixOS installer without any manual step?

I would say it’s possbile to do, but it’s not supported.
You could modify the partition scheme of the ISO image (nixos/modules/installer/cd-dvd/iso-image.nix) to add an extra partition, so that after you write the image onto a USB drive you can copy some files there, and then have it mounted over /var on boot.

It would probably be easier to script the bluetooth pairing, though.

1 Like

The idea is I do want to transplant the keys, so that BT keyboard would work on all the sites without unnecessary repairing again.

That’s right.
The only manual step would be needed to actually run the installer script.
Initially, I intended to avoid that also, but then decided it still would be useful to track the installation process via ssh.

1 Like