This splits the concern of how to display errors off from the business
logic. This should make it easier to test functionality and allow us
to concentrate on how to actually display and communicate errors to the
user. At some point this might also make i18n feasible, because you only
have to swap out a single file.
This hasn't quite fixed the debug/trace story yet. It should be possible
to simply insert a "debug" command into any pipeline and see the context
and state at that point.
For disk type, option name used in disk partlabel
naming should be short. While setting a specialized
option imageName allow us to create image with long name
without side-effects.
Some users will have `boot.zfs.forceImportRoot = false;` in their
configurations which conflicts with `boot.zfs.forceImportAll = true;`,
so we set it to `true` to match.
Usually this is added by nixos-generate-config.
However now that we run nixos-generate-config before disko or we even
run nixos-facter, we likely not see the LVM block devices anymore.
Use `zfs set -u` to update the `mountpoint` flag without mounting or
unmounting the filesystem. This flag was added in OpenZFS 2.2.0, which
was released October 2023.
The previous logic would not update `mountpoint` if `config.options` was
empty or only contained `mountpoint`.
As `makeDiskImages` always requires a NixOS configuration, we can
simplify the code by convering it into a NixOS module. Then we can make
it responsible for populating `system.build.diskoImages` and
`system.build.diskoImagesScript`.
This is not an issue when initially creating the partition because
device mapper will just map on top of the filesystem, but it breaks
incremental updates because the check for `TYPE=` will fail, and the
subsequent attempt to run `mkswap` also fails:
mkswap: cannot open /dev/disk/by-partlabel/disk-nix-store-swap: Device or resource busy
Instead, just don't do anything, NixOS will take care of it.
Running `zfs set mountpoint=/mnt/my-ds tank/my-ds`, ZFS may try to
unmount the dataset even if the mountpoint didn't change.
To avoid the confusing error message, this command is now only run when
the mountpoint actually changes.
This is needed to prevent two layers of emulation when offering a build for a host running binfmt such as an x86 host trying to compile for aarch64 via binfmt
This is especially useful when trying to build images for embedded systems such as the pi, which have a vendor kernel that can't be booted as part of the disko image builder process