Dynamically generating modules is easier than you’d expect,
def make_module(stuff) do
Module.create(derived_module_name(stuff), quote do
# your module body goes here
end,
Macro.Env.location(__ENV__))
end
As for running a .exs file, I think your best bet would be Code.eval_file/2. Also, depending on what you’re looking to do, you may want to look into Reactor: Read Me — reactor v0.4.1, as it may do what you’re looking to do already. And for defining the DSL you may look into Spark: Get Started With Spark — spark v1.1.53, which is a DSL building toolkit. Still sorely under-documented, but very feature rich. If you’re willing to read the tests to figure out how it works, then you’ll be A-ok. It’s very battle tested.