Belongs to d382a3cccf, but I authored that
on another machine.
Making sure vscode uses mypy from the environment is very important now,
because some of these errors get triggered in different ways depending
on the version.
There are still two issues: The type of "topology" in zpool is not
created, and gpt_partitions_options_hybrid_options for some reason
contains a `_create: "_create"` entry. This is an issue with the nix
evaluation, though, not with the code generator.
I'm fixing these issues manually to have some state I can start working
from.
This makes the tests more readable and easier to browse.
Making sure the tests always run fine, no matter from which directory
they're started is a little detail we should either test for or
document.
Using untyped dicts was not a safe way to pass arguments to error
message rendering. Also, having one giant match statement wouldn't scale
well. Using function pointers and kwargs, mypy can now properly check
whether all required arguments are passed to DiskoMessage().
As a bonus, it's now easy to use the "Go to definition" LSP command for
error codes, which wasn't possible before.
This requires a lot of restructuring. The .nix files have to be bundled
together with the python files, so they need to follow python's module
system structure.
I ran `nix-fast-build --no-link -j 2 --eval-workers 3 --flake .#checks`
and it succeeded, so I'm reasonably confident I changed everything as
required.
Error handling could be done better, but I'm pretty happy with it
already.
The important part is aggregating all errors instead of failing on the
first issue we encounter.
Previously, an error like
error: function 'anonymous lambda' called with unexpected argument 'customQemu'
at /nix/store/lbqj1cndic4121whnx8xm0jgb1c8x4xx-source/pkgs/build-support/vm/default.nix:1:1:
was printed when trying to evaluate `config.system.build.vmWithDisko` or
`config.system.build.diskoImagesScript` with nixpkgs 24.05 (and below).
This argument was added in
65c851cd75,
so technically the minimum version is 24.11.20240708.65c851c. However,
`versionAtLeast` only compares versions alphabetically, so the comparison's
result will be incorrect for other commits made on the same day.
Instead, we compare against 24.11.20240709, which is the next day.
This means this function returns false for some commits that DO support the
customQemu argument, but if it returns true, we can be 100% certain that this
is correct, and we can pass the customQemu argument to vmTools without an
evaluation error.
Fixes#850
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.
because it breaks evaluation on darwin with at least nix 2.18.
Evaluating `lib.splitString "" "foo"` throws the following:
`error: invalid regular expression ''`.
We could avoid that by using lib.stringToCharacters, but as
we are mapping over it anyway, lib.stringAsChars seems to be
an even better fit.
I tested the examples in hexEscapeUdevSymlinks docstring manually
in a nix repl.
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
```