CodeGen - simple, succint and customizable code generation for your libraries

That’s part of being more idiomatic too, see for example the official advice about not using config for libraries but instead passing options as function arguments. I think this code suggests a middle ground approach (so you could pass it as a function argument in any case, and redefine the default in your module if you’ve dumped the source:

defmodule CodeGenTemplate do
  @c1 1

  def f1(x, c1 \\ @c1) do
    x + c1
  end
end