← Back to context

Comment by nickjj

15 hours ago

It's neat that Hyprland lets you define layouts in its config but I like niri's approach.

It uses KDL (an established document / config language) and slightly extends it to add useful things like being able to include files.

For example, here's mine: https://github.com/nickjj/dotfriedrice/blob/master/.config/n...

What you end up with is a config file that's natural to read with no prior knowledge about anything and if you want to look something specific up, you know it's officially documented and not some home grown pattern someone created. There's a certain amount of comfort and stability you get with a "what you see is what you get" approach.

I never felt like I needed variables, conditions, functions or loops with niri's config.

I wouldn't call KDL "established"; it's honestly pretty niche. It looks _similar_ to pre-existing configuration formats, but KDL is very picky about syntax. I.e.: single word string MUST be quoted.

In this same space, https://codeberg.org/emersion/scfg/ is pretty widely used. The curious thing about scfg is that it's not really a "new" format: the syntax described has been in use by different tools for decades. They just didn't call it scfg, and it's mostly the name itself that's new.

  • It is picky, but picky is good. It's explicit which creates uniformity.

    For example with niri, if you forget quotes on a string value, you get this error.

        $ niri validate
        Error:   × error loading config
          ├─▶ error parsing
          ╰─▶ error parsing KDL
    
        Error:   × identifiers cannot be used as arguments
            ╭─[config.kdl:42:1]
         42 │         // Disable acceleration.
         43 │         accel-profile flat
            ·                       ──┬─
            ·                         ╰── unexpected identifier
         44 │     }
            ╰────
          help: consider enclosing in double quotes ".."

  • > picky about syntax. I.e.: single word string MUST be quoted.

    Seems like the opposite:

    Example from kdl website without quotes

    package { name my-pkg

    Example from scfg with quotes

    train "Shinkansen" {