Skip to content

Commit

Permalink
feat(types): add maybeRonRaw type
Browse files Browse the repository at this point in the history
Add maybeRonRaw type that allows either a raw RON value or a specified type.
Also fix recursive definition in options.nix by removing rec attribute set
and using explicit lib.cosmic.options reference.
  • Loading branch information
HeitorAugustoLN committed Jan 8, 2025
1 parent b680599 commit 0c8a130
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let
inherit (lib.cosmic.utils) nestedLiteral;
in
rec {
{
mkNullOrOption' =
{
type,
Expand All @@ -18,7 +18,8 @@ rec {
}
);

mkNullOrOption = type: description: mkNullOrOption' { inherit description type; };
mkNullOrOption =
type: description: lib.cosmic.options.mkNullOrOption' { inherit description type; };

mkSettingsOption =
{
Expand Down
16 changes: 16 additions & 0 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@
description = "hex color";
};

maybeRonRaw =
elemType:
let
ronFirst = with lib.types; either rawRon elemType;
elemFirst = with lib.types; either elemType rawRon;
in
ronFirst
// {
name = "maybeRonRaw";
inherit (elemFirst) description;
nestedTypes = {
inherit (lib.types) rawRon;
inherit elemType;
};
};

rawRon = lib.mkOptionType {
check =
value:
Expand Down

0 comments on commit 0c8a130

Please sign in to comment.