With help of the Inkscape community (special thanks to @rindolf), I could come up with a solution.
Prerequisites
- Python 2.7 (It won't work on newer versions)
- lxml ("pip install lxml")
Adjust Inkscape
Change 'GROUP = "{http://www.w3.org/2000/svg}g"' on line 36 of "tar_layers.py" in "Inkscape\share\extensions" to 'GROUP = "g"'. This has to be done, because your layers won't have that namespace.
Convert the DXF to multiple SVGs (one per layer)
Create an Inkscape SVG from the DXF:
python share/extensions/dxf_input.py input.dxf > output.svg
Export the layers as individual SVGs inside a tar:
python share/extensions/tar_layers.py output.svg > output.tar
Now, you should have a 'output.tar' file with Inkscape SVGs inside of it. If you need regular SVG, you have to export them like this:
inkscape -z -l output.svg input.svg
More information about the Inkscape CLI.