Replies: 6 comments 7 replies
-
I don't agree that the TOML syntax is that much easier. On the contrary, I think that the lack of indentation makes the config more difficult to understand. Either way, I wouldn't be necessarily opposed to switching from KDL to a more widely known format. However:
|
Beta Was this translation helpful? Give feedback.
-
side-note: we're working on a KDL 2.0 spec that would make these configs even nicer :) https://github.com/kdl-org/kdl/blob/29495006bc9eec4c508d60cd3b7de1d1f2773768/CHANGELOG.md For example, you'd be able to do:
All that said, I think KDL is a great fit and it makes me happy to see it get used here! I think it looks great. I think I'm gonna have to switch from Hyprland after all :) |
Beta Was this translation helpful? Give feedback.
-
Technically, TOML does allow indentation. However, TOML does not recommend indentation, and for a reason possibly worse, at least for niri's config, than a format that is overly picky about that: TOML does not prioritize nesting. Consequently, it has no way to name a table except from the root, or as an "inline table" (a table-value, in effect), which is limited to one line. This lack of affordances means there's not really a ton of good mid-points between [dependencies]
sample_crate = { version = "1.99.9-rc9", features = ["one", "two", "buckle-my-shoe"] } And a later evolution like: [dependencies.sample_crate]
version = "1.99.9-rc9"
default-features = false
registry = "ersatz-crates"
features = ["one", "two", "buckle-my-shoe"]
[target."cfg(all(target_env = "air", target_os = "jordans"))".dependencies.sample_crate]
features = [
"three",
"four",
"buckle-some-more",
"five",
"six",
"nike-kicks"
] If a configuration file may face deeply nested structures then it needs a better way to manage this than TOML affords. This is especially true with conditional relations, since the natural conditional is key lookup, nesting for each condition. As mere nesting can cause strife for TOML, and the overall structure is likely to remain similar per Yalter's response, the default-config.kdl already has samples that would suggest something other than TOML: niri/resources/default-config.kdl Lines 4 to 7 in 738d9a2 Any serious recommendations of alternatives would have to compensate for this. |
Beta Was this translation helpful? Give feedback.
-
I'd add a note as a person who suggested to move away from kdl a bunch of times in the past. However the reasons were mostly technically since the KDL implementation in rust brings a lot of deps(compared to TOML) and and unless the config was moved to its own crate with debug being literally always disabled (because otherwise niri binary is now ~ It was also adding to the fact that smithay itself tends to generate a lot of debug artifacts (though it doesn't really increase the binary that much), but it just increases
That's way nicer in TOML though, since it'll be just [input.keyboard.xkb]
layout = "us,ru" And you can write it like
if you want more fancy per-keyboard configs. Zero indention as well and just 2 lines, so it's not a real argument. The place where KDL really looks good is when arrays are involved, ihmo, that's why I suggested to use scfg instead, which is really simple as well and is what sway/i3 and a bunch of other libraries use, and it's simple to parse as well. But with scfg there're no good libs around it, nor people interested in making them in rust for the time being. There're a few really simple, but that's mostly it. So I'd say that TOML config is more compact in general, but it's a bit tricky to do bindings and global sections with it and in compositor the majority of what you have is actually bindings, rust toml libs are also not that great with error propagation (passing line/column is a pain), because serde devs just don't care about any of that and you can basically pass that only via globals or by using special containers, but those containers are basically the |
Beta Was this translation helpful? Give feedback.
-
FWIW, before release, as an experiment, I did a mostly-complete conversion to TOML to see how it would look like. You can see an example here: Line 576 in a4adf56 Later I remembered that you can disable debuginfo for specific dependencies, which solved my by far main issue with knuffel (the KDL parser we're using). |
Beta Was this translation helpful? Give feedback.
-
I went ahead and rewrote my config.kdl in kdl v2, and I think it feels a lot better. TBH I agree that it was kind of a pain, especially when configuring spawned commands. https://gist.github.com/zkat/beefc09ad8191dc7077290feceb19582 I also went ahead and played with changing how binding specification works, so instead of funny node names, you can just use arguments now:
I'll probably start updating kdl-rs soon and also see if I can add serde support in the process, but it might take me a bit :) |
Beta Was this translation helpful? Give feedback.
-
The syntax is more easy.
Beta Was this translation helpful? Give feedback.
All reactions