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).
Originally this was manually applied with;
```sh
nixpkgs-fmt **.nix && statix fix
```
but I overlooked the fact that `**.nix` would only expand to files in
the root (I should have used `**/*.nix`).
Previous commit adds `nix fmt` support which passes `.` to `nixpkgs-fmt`
(if no other path is explicitly specified when running `nix fmt`).
This commit includes the changes made by running `nix fmt`.
As discussed in [this
comment](https://github.com/nix-community/disko/pull/143#discussion_r1097912402),
as a blanket rule converting everything possible to `inherit` like
statements can hurt readability.
Add config file for statix to disable these checks and fixes, then rerun
the autofix with these options.
Apply standard formatting and some statix conventions using;
```sh
nixpkgs-fmt **.nix && statix fix .
```
With the intent of making contribution a bit easier and reducing mental
load in hand formatting (in the same vein as [black]).
[black]: https://github.com/psf/black#the-uncompromising-code-formatter