deploy install
In the context of https://devos.divnix.com/doc/start/bootstrapping.html, it would be nice if deploy-rs could handle to install onto /mnt just as the official installer during bootstrapping operations.
While it is currently possible to (almost) fully remote bootstrap, except for sticking the usb into the host, using deploy-rs for the initial deployment onto /mnt has the added benefit of having a single and uniform workflow from generation 1, already.
There are probably more benefits waiting downstream.
This sounds like a pain in the ass... but, it's something I definitely want. Some benefits that come to mind are:
multi-profile deployments even on local machines, I personally use deploy-rs to deploy system and home-manager separately, but on new machines I am forced to first install NixOS, then reboot, then install deploy-rs, and my updated closures to deploy.
Decreased latency in deploying new nodes, if you quickly need to bring a new bare server online, going through the normal steps can add a lot of delay and potential issues which are more difficult to debug outside of a single atomic deployment.
Easily fully automated deployments, with this implemented it should be trivial to generate a NixOS ISO which deploys every single Nix profile, system included to a bare system, this can worth both with an interface that queries for target mount and GRUB drive, or have that be hardcoded within the ISO, both are useful in numerous circumstances.
One thing to keep in mind: the installer may ask for resetting the password. So proper (interactive) piping of stdin/out/err over the network is one prerequisite.
I quickly sifted through instances of mountPoint in https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/tools/nixos-install.sh
the relevant picks:
nix-env --store "$mountPoint" "${extraBuildFlags[@]}" \
--extra-substituters "$sub" \
-p "$mountPoint"/nix/var/nix/profiles/system --set "$system" "${verbosity[@]}"
# is this necesary ?
install -m 0700 -d "$mountPoint"/root/.nix-defexpr
# Mark the target as a NixOS installation, otherwise switch-to-configuration will chicken out.
mkdir -m 0755 -p "$mountPoint/etc"
touch "$mountPoint/etc/NIXOS"
echo "installing the boot loader..."
# Grub needs an mtab.
ln -sfn /proc/mounts "$mountPoint"/etc/mtab
NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root "$mountPoint" -- /run/current-system/bin/switch-to-configuration boot
the last one is a bit "interesting" and I don't immediately grok what this does or why it does what it does the way it does through "piloting".
Edit: doesn't seem like the switch-to-configuration boot does an awful lot but boot loader installer like these probably still need a nixos-enter environment to have all implicit contracts satisfied.