Fixes#900
This was caused by https://github.com/NixOS/nixpkgs/pull/354535
originally. The breaking changes introduced there have been resolved by
https://github.com/NixOS/nixpkgs/pull/360413, but one addition survived,
which was the line `source $stdenv/setup`.
Because we used `>` instead of `>>`, `saved-env` was overwritten, so
even with the second PR, the script failed with the following error:
/nix/store/pw...ykc-vm-run-stage2: line 16: stdenv: unbound variable
Once this and the second PR mentioned above are merged, #903 will be
unblocked.
It seems that there is a difference between how `pkgs` and `lib` get
passed to NixOS modules: `pkgs` is the unmodified original, `lib` is the
final version after overrides etc.
This causes `pkgs.lib.version` to be `24.11git` in some cases, while
`lib.version` is `24.11.20241123.0c58267`.
Maybe this can be fixed in nixpkgs? Either way, this change fixes that
issue.
Fixes#904
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.
The type keyword was included before every vdev:
```shell
zpool create -f <name> /dev/sda log mirror /dev/sdb /dev/sdc log mirror /dev/sdd /dev/sde
```
but this is incorrect and should instead be:
```shell
zpool create -f <name> /dev/sda log mirror /dev/sdb /dev/sdc mirror /dev/sdd /dev/sde
```
Fixes#871
Previously, if a user used v2.10.0 (currently unreleased master), an
error like this would be displayed:
error: attribute '_cliDestroyFormatMount' missing
at /nix/store/fbqgaij9d3b373rq1iav5glzr4dy77qf-disko/share/disko/cli.nix:73:7:
72| else if (lib.traceValSeq hasDiskoModuleFlake) then
73| (builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}
| ^
74| else
This situation now produces a more helpful error:
Error: Attribute `nixosConfigurations.testmachine.config.system.build._cliDestroyFormatMount`
not found in flake `/home/felix/repos-new/disko`!
This is probably caused by the locked version of disko in the flake
being different from the version of disko you executed.
EITHER set the `disko` input of your flake to `github:nix-community/disko/latest`,
run `nix flake update disko` in the flake directory and then try again,
OR run `nix run github:nix-community/disko/v1.9.0 -- --help` and use one of its modes.