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.
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
As `makeDiskImages` always requires a NixOS configuration, we can
simplify the code by convering it into a NixOS module. Then we can make
it responsible for populating `system.build.diskoImages` and
`system.build.diskoImagesScript`.
This is needed to prevent two layers of emulation when offering a build for a host running binfmt such as an x86 host trying to compile for aarch64 via binfmt
This is especially useful when trying to build images for embedded systems such as the pi, which have a vendor kernel that can't be booted as part of the disko image builder process
fixes an error when using this minimal configuration:
```nix
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11") { };
disko = fetchTarball "https://github.com/nix-community/disko/tarball/master";
in
pkgs.nixos {
imports = [
"${disko}/module.nix"
"${disko}/example/hybrid.nix"
];
}
```
when running:
```console
$ nix-build
...
error: 'default' at /nix/store/y981rwszq9yi36rvvz2vrr6hb22si0hc-source/lib/default.nix:391:23 called with unexpected argument 'system'
```
I do build my workstation with `documentation.nixos.includeAllModules`
to also have private modules and external stuff in my local options'
reference.
Not sure why exactly this breaks with
error: attribute 'loader' missing
at /nix/store/h6qicay9fgggx9nf6apdl6zkdpdp28xx-source/module.nix:46:19:
45| type = lib.types.bool;
46| default = config.boot.loader.systemd-boot.enable || config.boot.loader.grub.efiSupport;
| ^
47| };
but using defaultText is the usual fix that also works here.
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