lib/options: add mkNullOrOption' variant

This commit is contained in:
Matt Sturgeon 2024-05-31 19:14:45 +01:00
parent 57003fea4e
commit fc542329cd
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -7,13 +7,20 @@ with lib;
with nixvimUtils; with nixvimUtils;
rec { rec {
# Creates an option with a nullable type that defaults to null. # Creates an option with a nullable type that defaults to null.
mkNullOrOption = mkNullOrOption' =
type: desc: {
lib.mkOption { type,
type = lib.types.nullOr type; default ? null,
default = null; ...
description = desc; }@args:
}; lib.mkOption (
args
// {
type = lib.types.nullOr type;
inherit default;
}
);
mkNullOrOption = type: description: mkNullOrOption' { inherit type description; };
mkCompositeOption = desc: options: mkNullOrOption (types.submodule { inherit options; }) desc; mkCompositeOption = desc: options: mkNullOrOption (types.submodule { inherit options; }) desc;