LordMZTE f695251d79
ci/woodpecker/push/woodpecker Pipeline was successful Details
feat: add toJSON lua function
2023-09-02 13:46:00 +02:00
src feat: add toJSON lua function 2023-09-02 13:46:00 +02:00
.gitignore feat: initial commit 2023-01-20 21:30:02 +01:00
.woodpecker.yml ci: check formatting 2023-08-06 19:01:21 +02:00
LICENSE docs: add a README and a LICENSE 2023-01-20 21:46:30 +01:00
README.md docs: add a README and a LICENSE 2023-01-20 21:46:30 +01:00
build.zig feat: improve CLI and take confgen file as CLI argument 2023-05-01 23:09:11 +02:00
build.zig.zon revert 4d129a0692 2023-08-26 15:14:50 +02:00



confgen is a tool to generate config files using a custom template language.

The system is backed by a Lua runtime that is used to configure the tool.


Start by creating confgen.lua in your dotfiles. It should look something like this:

-- add your config files
cg.addString("my_config.cfg", [[config template here]])
cg.addFile("my_other_config.cfg", "out.cfg") -- with output path
cg.addPath(".config") -- add a whole path recursively

-- set options to be used in config files
cg.opt.test_option = "42"

Next, add some templates. confgen will detect if a file is a template by its extension and copy it otherwise. This is what a template looks like:

I'm a confgen template!
<! if some_condition then !> # any lua statement
some option: <% opt.test_option %> # a lua expression
<! end !> # close the if block
more config stuff

Template files end with the .cgt extension. If a file that has been added has this extension, confgen will evaluate the template and put that into the output directory (without the .cgt extension), otherwise, it will be copied.

For example, if you want to add a file called stuff.cfg to the output as a template, you'd call the template file stuff.cfg.cgt.

With the above confgen.lua, this template

<! for i = 0,5 do !><% i %><! end !>

<% opt.test_option %>

would result in this output.



Lastly, run confgen, providing the output directory as an argument:

confgen out_dir



  • install the luajit library and the master version of Zig
  • zig build -Drelease-fast -p ~/.local


This is untested, but it should work theoretically.


no lol