Five coupled changes that must land together because they form one
atomic refactor of disko's test-option surface:
- Define `installTestEval` in the let-block via
`nixos-lib.evalTest`, importing `./lib/install-test.nix` and
threading `diskoLib`, `diskoDevices` (and indirectly `pkgs` via
`hostPkgs`) into the test eval's module args. Propagate the
host-level `networking.hostId` to every node via the framework's
native `defaults` hook — single source of truth, so
`lib/install-test.nix` drops its per-node hostId setter on
`nodes.formatter` (the host eval's hostId now flows to formatter
and machine identically).
- Declare `options.disko.test` as a submodule whose type is borrowed
from `installTestEval.type` — i.e. the full NixOS-test option tree
(`nodes`, `testScript`, `defaults`, `globalTimeout`, …) plus the
seven disko knobs declared in `./lib/install-test.nix`. Add
`diskoTest = lib.mkDefault config.disko.test.test;` to the
`system.build` attrset next to the existing
`installTest = makeDiskoTest { … };` (the legacy definition stays
for this commit).
- Delete the flat `disko.tests.{bootCommands,efi,enableOCR,extraChecks,extraConfig}`
declarations from the `options.disko` block. Drop the now-deleted
`config.disko.tests.extraConfig` import from `vmVariantWithDisko`'s
`extendModules` call.
- Add migration modules to the imports list:
- `mkRemovedOptionModule` for `disko.tests.extraConfig` with a
message pointing users at `disko.test.defaults` /
`virtualisation.vmVariantWithDisko = { imports = [ … ]; };`.
- 8 × `mkRenamedOptionModule` redirecting flat knobs into the
`disko.test` submodule. Existing user configs keep working with
one deprecation warning per renamed setter.
- Update `lib/interactive-vm.nix:66`: `config.disko.tests.efi` →
`config.disko.test.efi`. The legacy path would still resolve via
the rename but emit a deprecation warning on every interactive-VM
eval — update the callsite to be quiet.
The legacy `installTest = makeDiskoTest { … };` in the `system.build`
attrset is left in place but its read of `cfg.tests.extraConfig` is
dropped (the option no longer exists; the other reads forward through
`mkRenamedOptionModule`). The next commit replaces its RHS with
`lib.mkDefault config.disko.test.test` so both attrset entries point at
the same drv.
Three new files that will replace the manual-merging body of
`makeDiskoTest` in lib/tests.nix:
- lib/install-test.nix: pure NixOS test module declaring
the 7 disko convenience knobs
(extraChecks, bootCommands, boot,
efi, postDisko, enableCanokey, mode)
alongside the config that consumes
them. Owns the nodes.{formatter,
machine} blocks and the testScript.
The formatter's `../module.nix`
import is gated on
`config.mode == "module"` —
`direct` mode uses pre-built
standalone CLI scripts and doesn't
need the module's
`system.build.{format,mount,…}`
derivations.
- lib/install-test-formatter.nix: per-node base for the formatter VM
(test-instrumentation + qemu-guest +
swraid + nix.settings tweaks).
Disko module + `disko.enableConfig =
false`/`checkScripts = true` /
forced `disko.devices` are set by
`install-test.nix` only in
`mode = "module"`.
- lib/install-test-machine.nix: per-node base for the booted system
being tested. Imports the disko
module unconditionally (the booted
system always needs disko's
generated fileSystems/boot/swapDevices).
Nothing imports these yet; the files are inert until the next commit
wires `disko.test` as the host eval's submodule pointing at them.
Part of the makeDiskoTest -> evalModules refactor outlined in
`~/.claude/plans/disko-test-refactor.md`.
`prepareDiskoConfig` strips disko's `_`-prefixed internal attrs
(`_config`, `_meta`, `_create`, `_mount`, `_unmount`, `_pkgs`) —
every disko submodule declares these as `internal = true; readOnly =
true` with computed defaults. The function then reassigns the cleaned
value to `disko.devices` on a fresh module eval; if any `_*` attrs
leak through, the node eval's readOnly defaults collide with the
carried-through values and the merge errors.
The original implementation used `lib.filterAttrsRecursive` which
only descends into attrsets, not list elements. The legacy
`partitions = [ … ]` list (the disko `table` content type) therefore
kept its `_config` per entry — the well-known "set multiple times"
error called out in `lib/types/table.nix`'s deprecation warning.
Replace it with a small `deepStripUnderscore` helper that descends
into both attrsets and lists. Adds a TODO: this whole-tree rewrite
becomes unnecessary once test-time substitution moves to per-leaf
`disko.devices.disk.<name>.device = lib.mkForce …;` overrides on the
existing module-system value (rather than reassigning the whole
`disko.devices` value), which is the natural evolution of the
disko.test refactor.
This introduces what has been described in
https://0pointer.net/blog/unlocking-luks2-volumes-with-tpm2-fido2-pkcs11-security-hardware-on-systemd-248.html.
That is: support for FIDO2 and recovery passphrases and their boot
mechanism.
Testing is hard right now because of canokey-qemu being broken and U2F
is not a valid replacement for FIDO2…
I tried to keep as much as possible the previous behavior and make it
possible to mix FIDO2 and normal passphrases or key files without any
problem.
PIV support is out of scope for this change but can easily be added.
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
Use the `fsBefore` function from NixOS to sort the file-systems.
The function originates from `nixpkgs/nixos/lib/utils.nix`, but the file
is a lambda that requires more arguments than we have available.
Use the `fsBefore` function from NixOS to sort the file-systems.
The function originates from `nixpkgs/nixos/lib/utils.nix`, but the file
is a lambda that requires more arguments than we have available.
The device of the bind mounts is incorrectly taken verbatim while making
the image. The root hierarchy is mounted at `config.rootMountDir`
(`/mnt` by default) during the process, and this commit prepends that
path to the `device` in these cases.
Nix refuses to operate when the store path or its parent directories
contain symlinks. On some systems /mnt can be a symlink, causing
disko-install to fail with:
error: the path '"/mnt"' is a symlink; this is not allowed for the
Nix store and its parent directories
Use realpath to resolve symlinks before passing the mount point to
nix-store and nixos-install commands.
Allow users to override the automatic thread count detection for nix
store copying. The default "auto" behavior remains unchanged (min of
nproc and 8), but users can now specify a fixed thread count for
environments where the automatic detection isn't optimal.
The value for device is copied into the SOURCE column of findmnt.
By default this is "none". The mount and unmount scripts
branch on SOURCE=fsType specifically, and the existence of "none"
in the SOURCE column causes wrong branches to be executed.
For a list of special filesystems, the default value "none"
is replaced by the value for fsType.
QEMU on aarch64 requires an explicit machine type (e.g., '-machine virt'),
unlike x86_64 which has a default. Previously, the test script hardcoded
'qemu-kvm' without machine type arguments, causing aarch64 tests to fail
with "No machine specified, and there is no default".
By importing and using nixpkgs' qemu-common.nix library, we reuse the
existing platform-specific QEMU configuration logic.
Even though we don't depend on the MBR bootable flag in the following
steps, not running udevadm trigger and waiting for settle can cause
/dev/disk/by-partlabel entries to be absent when formatting filesystems
immediately after modifying the partition table.
The device of the bind mounts is incorrectly taken verbatim while making the image.
The root hierarchy is mounted at `config.rootMountDir` (`/mnt` by default) during the process,
and this commit prepends that path to the `device` in these cases.
fixes device groups, for example where the disko config given looks like:
label = "fast.dev1";
after formatting, the device has a literal label of "fast.dev1" which
breaks bcachefs device groups:
echo fast > /sys/fs/bcachefs/<id>/options/foreground_target
gives the error Invalid argument, echo fast.dev1 fails as well
echo "\"fast\"" fails the same, however echo "\"fast.dev1\"" succeeds
after this, device labels and groups work as expected and any component
of the label can be used for a *_target