Files
disko/example
Michael Hoang 1be12abec3 example/luks-interactive-login: cover the install-test override mechanism
Extend the example so it doubles as a test that asserts
`disko.test.defaults` propagates to both install-test nodes:

  - A test-only LUKS password (`pkgs.writeText "luks-test-password"
    "custompassword"`) is set via `disko.test.defaults` — the test
    framework's "imported into every node" hook. The example's
    user-facing default (`passwordFile = "/tmp/secret.key";`) is
    preserved for anyone importing this file into their own NixOS
    config; the override fires only inside `system.build.diskoTest`.

  - `bootCommands` types `custompassword\n` at the LUKS prompt. For
    the unlock to succeed, format must have encrypted with the same
    password — i.e. `defaults` must propagate to `nodes.formatter`
    (which runs `disko format`) as well as `nodes.machine` (whose
    initrd prompts at boot).

  - `extraChecks` asserts the LUKS volume exists at the expected
    device path and `/` is mounted.

If `defaults` ever stops propagating to the formatter, format would
encrypt with the example's `/tmp/secret.key` default
(`secretsecret`, written by the test framework's testScript) while
`bootCommands` types `custompassword` — the initrd's LUKS unlock
fails and the test catches the regression at the boot phase.

KNOWN ISSUE: `defaults` does NOT currently propagate to
`disko.devices.*` paths under the existing `install-test.nix`
shape. `install-test.nix` sets `disko.devices = testConfigBooted.disko.devices`
on each node as a whole-attrset definition; the user's leaf override
from `defaults` is buried inside its outer-attrset wrapper and
discarded by the priority filter at the `disko.devices` option,
regardless of `lib.mkForce` on the leaf. As a result this test
currently FAILS at the boot phase — by design, since that failure is
the assertion. Future work: narrow `install-test.nix`'s per-node
`disko.devices` setter to leaf-level
`disk.<name>.device = lib.mkForce …` overrides so the surrounding
content tree (including user `defaults` overrides) flows through
the existing host-eval value. When that lands, this test starts
passing.
2026-05-18 15:50:44 +02:00
..