fix: properly apply oneOf

This commit is contained in:
dylan madisetti committed 2024-08-26 14:00:44 -04:00
1 parent ea3ce722ea
commit c9d3bc3755
4 files changed
+69 -66

No files matched your search

+1 -1
View File
@@ -90,7 +90,7 @@
special = { special = {
members = [ "z" ]; members = [ "z" ];
}; };
cache = "cache"; cache = [ "cache" ];
}; };
}; };
+1
View File
@@ -100,3 +100,4 @@
}; };
}; };
} }
-1
View File
@@ -53,4 +53,3 @@
}; };
}; };
} }
+67 -64
View File
@@ -25,72 +25,75 @@ in
}; };
mode = lib.mkOption { mode = lib.mkOption {
default = ""; default = "";
type = (lib.types.enum modeOptions) // (lib.types.attrsOf (diskoLib.subType { type = (lib.types.oneOf [
types = { (lib.types.enum modeOptions)
topology = (lib.types.attrsOf (diskoLib.subType {
let types = {
vdev = lib.types.submodule ({ name, ... }: { topology =
options = { let
mode = lib.mkOption { vdev = lib.types.submodule ({ name, ... }: {
type = lib.types.enum modeOptions; options = {
default = ""; mode = lib.mkOption {
description = "Mode of the zfs vdev"; type = lib.types.enum modeOptions;
default = "";
description = "Mode of the zfs vdev";
};
members = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Members of the vdev";
};
}; };
members = lib.mkOption { });
type = lib.types.listOf lib.types.str; parent = config;
description = "Members of the vdev"; in
lib.types.submodule
({ config, name, ... }: {
options = {
type = lib.mkOption {
type = lib.types.enum [ "topology" ];
default = "topology";
internal = true;
description = "Type";
};
# zfs device types
vdev = lib.mkOption {
type = lib.types.listOf vdev;
default = [ ];
description = ''
A list of storage vdevs. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Virtual_Devices_(vdevs)
for details.
'';
example = [{
mode = "mirror";
members = [ "x" "y" "/dev/sda1" ];
}];
};
special = lib.mkOption {
type = lib.types.nullOr vdev;
default = null;
description = ''
A vdev definition for a special device. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#special
for details.
'';
};
cache = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = null;
description = ''
A dedicated zfs cache device (L2ARC). See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Cache_Devices
for details.
'';
};
# TODO: Consider supporting log, spare, and dedup options.
}; };
}; });
}); };
parent = config; extraArgs.parent = config;
in }))
lib.types.submodule ]);
({ config, name, ... }: {
options = {
type = lib.mkOption {
type = lib.types.enum [ "topology" ];
default = "topology";
internal = true;
description = "Type";
};
# zfs device types
vdev = lib.mkOption {
type = lib.types.listOf vdev;
default = [ ];
description = ''
A list of storage vdevs. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Virtual_Devices_(vdevs)
for details.
'';
example = [{
mode = "mirror";
members = [ "x" "y" "/dev/sda1" ];
}];
};
special = lib.mkOption {
type = lib.types.nullOr vdev;
default = null;
description = ''
A vdev definition for a special device. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#special
for details.
'';
};
cache = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = null;
description = ''
A dedicated zfs cache device (L2ARC). See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Cache_Devices
for details.
'';
};
# TODO: Consider supporting log, spare, and dedup options.
};
});
};
extraArgs.parent = config;
}));
description = "Mode of the ZFS pool"; description = "Mode of the ZFS pool";
}; };
options = lib.mkOption { options = lib.mkOption {