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`.
`example/luks-fido2.nix` has been pure example up to now — no
corresponding install-test. Add `tests/luks-fido2.nix` using the
existing `makeDiskoTest` shim, exercising the FIDO2-enrolled LUKS path:
- `enableCanokey = true` attaches a virtual Canokey to both the
formatter VM (where disko runs `systemd-cryptenroll
--fido2-device=auto` during the format phase) and the booted machine
(where the initrd auto-unlocks LUKS via FIDO2). Canokey emulates a
FIDO2 token at `/dev/hidraw*` and answers programmatically, so
neither phase needs a user tap.
- `extraTestScript` asserts the LUKS volume exists at the expected
device path and `/` is mounted — which is only true if the initrd's
FIDO2 unlock succeeded.
Added in the pre-refactor (legacy `makeDiskoTest` function-call) shape
so the subsequent tests/ modulification commit converts it alongside
the other tests in one sweep.
`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.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* FIDO2 token enrollment for LUKS-encrypted root with optional automatic
recovery passphrase and new configuration options to control enrollment
behavior.
* **Examples**
* Added an example configuration demonstrating a FIDO2-protected disk
layout (ESP + encrypted root) with FIDO2 enrollment enabled.
* **Tests**
* Added automated test coverage for the FIDO2/LUKS workflow and a
test-mode option to simulate a hardware FIDO2 device.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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>
Previously, the `disk-deactivate` script stopped mdadm arrays before
wiping the underlying physical disks. This caused filesystems with
backup superblocks (like BTRFS at 64 MiB and 256 GiB offsets) to
survive the wipe, as the backups were striped across the physical
disks and missed by `wipefs` on the raw block devices.
When the array was reassembled during reprovisioning, the filesystem
superblocks realigned. `disko` would detect the old filesystem via
`blkid` and silently skip the `mkfs` step, leaving stale data intact.
This commit adds a `wipefs --all` command against the assembled RAID
device *before* stopping it, ensuring all filesystem signatures and
backup superblocks are cleanly destroyed.
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.
Automated changes by the
[update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock)
GitHub Action.
```
Flake lock file updates:
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/48698d12cc10555a4f3e3222d9c669b884a49dfe?narHash=sha256-yxgb4AmkVHY5OOBrC79Vv6EVd4QZEotqv%2B6jcvA212M%3D' (2026-01-25)
→ 'github:NixOS/nixpkgs/e3cb16bccd9facebae3ba29c6a76a4cc1b73462a?narHash=sha256-jpfPdBjKO232s5NueoNEvvVzpndiUzPLNYcH4/Ov0gY%3D' (2026-02-15)
```
### Running GitHub Actions on this PR
GitHub Actions will not run workflows on pull requests which are opened
by a GitHub Action.
**To run GitHub Actions workflows on this PR, close and re-open this
pull request.**
Automated changes by the
[update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock)
GitHub Action.
```
Flake lock file updates:
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/3327b113f2ef698d380df83fbccefad7e83d7769?narHash=sha256-MJwOjrIISfOpdI9x4C%2B5WFQXvHtOuj5mqLZ4TMEtk1M%3D' (2026-01-17)
→ 'github:NixOS/nixpkgs/48698d12cc10555a4f3e3222d9c669b884a49dfe?narHash=sha256-yxgb4AmkVHY5OOBrC79Vv6EVd4QZEotqv%2B6jcvA212M%3D' (2026-01-25)
```
### Running GitHub Actions on this PR
GitHub Actions will not run workflows on pull requests which are opened
by a GitHub Action.
**To run GitHub Actions workflows on this PR, close and re-open this
pull request.**