Igniter - A code generation and project patching framework


Igniter is a code generation and project patching framework.

For library authors, this is a tool kit for writing smarter generators that can semantically modify existing files, and all sorts of useful tools for doing so.

For end-users, this means mix igniter.install <package>, which will add it to your mix.exs automatically and then run that library’s installer if it has one. Even when libraries don’t have an installer, or use igniter, this behavior makes it useful to keep around.


Igniter can be added to an existing elixir project by adding it to your dependencies:

{:igniter, "~> 0.1", only: [:dev]}

You can also generate new projects with igniter preinstalled, and run installers in the same command.

mix igniter.new app_name --install ash

To use this command, install the archive:

mix archive.install hex igniter_new


Mix tasks built with igniter are both individually callable, and composable. This means that tasks can call eachother, and also end users can create and customize their own generators composing existing tasks.


Igniter will look for a task called <your_package>.install when the user runs mix igniter.install <your_package>, and will run it after installing and fetching dependencies.


These can be run like any other mix task, or composed together. For example, lets say that you wanted to have your own Ash.Resource generator, that starts with the default mix ash.gen.resource task, but then adds or modifies files:

# in lib/mix/tasks/my_app.gen.resource.ex
defmodule Mix.Tasks.MyApp.Gen.Resource do
  use Igniter.Mix.Task

  def igniter(igniter, [resource | _] = argv) do
    resource = Igniter.Code.Module.parse(resource)
    my_special_thing = Module.concat([resource, SpecialThing])
    location = Igniter.Code.Module.proper_location(my_special_thing)

    |> Igniter.compose_task("ash.gen.resource", argv)
    |> Igniter.create_new_elixir_file(location, """
    defmodule #{inspect(my_special_thing)} do
      # this is the special thing for #{inspect()}

I’m so excited to see where this tool goes!




PS. The Hex link in the badge in the GitHub README has an extra h in it.

1 Like

This looks super sweet!

I’m making a package that chains mix tasks to generate projects from blueprints, configured from livebook smart cells.

I’ll definitely be adding Igniter to the system. If only you’d published this earlier I would’ve had a lot fewer headaches :slightly_smiling_face: :rofl:

1 Like

Fixed! And thanks for posting the links. In the guide lines it says not to link to external sources but I think I took that too literally. It means “explain your package here”, not “don’t have any links pointing elsewhere” :laughing:

With mix igniter.install, you can install multiple packages at once! Use the @ symbol to specify specific versions, git/GitHub dependencies, or even path dependencies!

1 Like

:clap: Kudos to @zachdaniel and everyone else that has been contributing to the Ash Framework. However you feel about adopting Ash itself, so many great libraries keep spinning out of that effort!

(If you haven’t yet, also check out Spark.)


Hi @zachdaniel I wanted to ask if I am trying to generate a directory of Ecto.Schema models in my project based on an open-api specification, is Igniter a good fit? Is it an intended use?

If the api changes, I would blow away and regenerate those models.

In that case, you likely do not need igniter. Only if you wanted to support changes being made to the schema files and retaining them while patching in new updates from the open api spec.

1 Like

Awesome work! Can’t wait to try it out and try to replace some of the handwritten generators I have in our mix directory like this one operately/lib/mix/tasks/operately.gen.api.query.ex at main · operately/operately · GitHub.

Hopefully, it could be just a drop-in replacement for what we already have, but with a polished and well thought through system.

1 Like