diff --git a/lib/default.nix b/lib/default.nix index 4a21b43..9d8d11d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,9 +1,15 @@ { lib, ... }: +let + generators = import ./generators.nix { inherit lib; }; +in { + inherit generators; + applets = import ./applets.nix { inherit lib; }; applications = import ./applications.nix { inherit lib; }; - generators = import ./generators.nix { inherit lib; }; modules = import ./modules.nix { inherit lib; }; options = import ./options.nix { inherit lib; }; utils = import ./utils.nix { inherit lib; }; + + inherit (generators) ron; } diff --git a/lib/generators.nix b/lib/generators.nix index 462d29c..9d835de 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -171,4 +171,49 @@ .${type} or (throw "lib.cosmic.generators.toRON: ${type} is not supported."); in toRON'; + + ron = + type: value: + { + char = { + __type = "char"; + inherit value; + }; + enum = + if builtins.isAttrs value then + if + builtins.attrNames value == [ + "value" + "variant" + ] + then + { + __type = "enum"; + inherit (value) value variant; + } + else + throw "lib.cosmic.ron: enum type must receive a string or an attribute set with value and variant keys value" + else + { + __type = "enum"; + inherit value; + }; + map = { + __type = "map"; + inherit value; + }; + optional = { + __type = "optional"; + inherit value; + }; + raw = { + __type = "raw"; + inherit value; + }; + tuple = { + __type = "tuple"; + inherit value; + }; + } + .${type} or (throw "lib.cosmic.ron: ${type} is not supported."); }