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.
For each `tests/foo.nix` with a 1:1 corresponding `example/foo.nix`,
move the `disko.test = { … };` block (and any host-level overrides
like `networking.hostId`, `disko.devices.X = lib.mkForce Y`,
`_module.args.disks`) from the test file into the example. Delete the
now-empty `tests/foo.nix`. Now every example file doubles as its own
install-test reachable via
`nix build .#nixosConfigurations.<x>.config.system.build.diskoTest`
when the example is imported into a NixOS config.
Two example renames to preserve the baseline check key (which the plan
requires to stay unchanged):
- `example/xfs-with-quota.nix` → `example/xfs.nix`
(tests/xfs.nix's name was "xfs", not "xfs-with-quota")
- `example/gpt-name-with-whitespace.nix` →
`example/gpt-name-with-special-chars.nix`
(tests/gpt-name-with-special-chars.nix's name was the latter)
`tests/default.nix` now scans `example/` in addition to `tests/` and
merges via `exampleDirModule // testsDirModule` (tests/ wins on name
collision — relevant for cli/module which share example/complex.nix
with distinct `disko.test.mode` overrides).
Files that stay in `tests/`:
- `default.nix` — discovery driver
- `cli.nix` and `module.nix` — both import `example/complex.nix`
and override `disko.test.{name, mode, extraChecks}` via
`lib.mkForce` to cover the standalone-CLI vs module-eval test paths
- `standalone.nix`, `make-disk-image.nix`,
`make-disk-image-impure.nix`, `mdadm-btrfs-wipe.nix` — bespoke
tests that don't fit the example-eval pattern
End state: 7 `.nix` files in `tests/` (plus the `disko-install/`
subdirectory); 39 self-tests in `example/` (each example is its own
test).
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>
Just did the mistake to copy and paste one legacy table type example.
Ran into the warning and was a bit sad.
Adding these comments while referring to the documentation could help
some undercaffeinated disko users like me.
This update introduces a bcachefs type with encryption support and advanced formatting options.
It includes a new example (`examples/bcachefs-multi-disk.nix`) to demonstrate multi-disk setups and available options.
Key changes:
- Deterministic UUID generation.
- Addressed limitations with multi-disk root setups due to bcachefs and systemd issues.
- Provided a systemd-mount alternative for fileSystems configuration.
- Added subvolume support and updated scripts for clarity and functionality.
---------
Co-authored-by: Jonas Heinrich <onny@project-insanity.org>
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
Co-authored-by: Kyle Petryszak <6314611+ProjectInitiative@users.noreply.github.com>
Update
* Add examples
* Improve descriptions
Remove debugging
Remove comment
Use `unique` to dedup lists
This is the only way to assign devices rather than fixed gpt partitions.
Without reading the code it's not very obvious how disko actually
assigns devices to zpools.
A config like
```nix
{
vdev = [
{
mode = "mirror";
members = [ "data1" "data2" ];
}
{
members = [ "data3" ];
}
];
}
```
would result in the following command:
```shell
zpool create -f <name> mirror /dev/data1 /dev/data2 /dev/data3
```
which would result in a single vdev with a 3-way mirror, rather than a
vdev with a 2-way mirror and a second vdev with a single disk. By
reordering the vdevs to handle those with an empty mode first we
transform this into:
```shell
zpool create -f <name> /dev/data3 mirror /dev/data1 /dev/data2
```
which does have the desired outcome.
lvcreate -l does not accept a '100%' parameter which currently leads to a crash. THis change automatically changes `100%` to `100%FREE` leading to the intended behavior.
Fixes#130
This should fix pretty much all cases where spaces or other special
characters would break disko due to improper quoting. I searched for all
instances of '.label', '.device' and '.name', so I believe I caught
whatever I could.
In some cases I changed single quotes to double quotes for consistency.
I know we don't usually fix bugs in the legacy table type, but it was so
easy I couldn't resist.
Reproduces #130.
For new style table the generated script has a few problems for example;
```sh
sgdisk \
--new=2:0:+100M \
--change-name=2:disk-vdb-name with spaces \
--typecode=2:EF00 \
/dev/vdb
```
and
```sh
mkfs.vfat \
\
/dev/disk/by-partlabel/disk-vdb-name with spaces
```
Legacy table style generates slightly different problems e.g.;
```sh
parted -s /dev/vdb -- mkpart name with spaces 1MiB 100MiB
```