Skip to content

Use ronix for RON ↔ Nix conversion to reduce duplication and enable config migration #53

Description

@caniko

Hey Heitor! I just authored ronix, a RON ↔ Nix interop library. While working on it I realized that cosmic-manager maintains its own pure-Nix RON parser and serializer in lib/ron.nix — and it turns out we've independently arrived at the same design: both projects use __type-tagged attrsets to represent RON types that don't map directly to Nix (enums, tuples, chars, optionals, maps, named structs).

Since we're solving the same problem with the same approach, I think it'd make sense for cosmic-manager to use ronix as a dependency instead of maintaining its own ~500-line implementation. This would free up maintenance effort and let both projects benefit from shared bug fixes and improvements.

What ronix brings to the table

The Nix library (nix/lib.nix) provides drop-in equivalents for everything in lib/ron.nix:

  • toRON / fromRON / importRON — same as cosmic-manager's, same __type convention
  • mkRON constructors (.char, .optional, .tuple, .enum, .map, .namedStruct, .raw)
  • isRONType predicate
  • mkRonService — a NixOS helper for RON-configured systemd services

On the Rust side, ronix also has a serde::Serializer that can turn any Rust struct into a valid Nix expression, plus a CLI interface — but the Nix library alone covers what cosmic-manager needs.

Bonus: migrating existing COSMIC configs

One thing this could unlock is a config migration tool. Right now, users switching to cosmic-manager have to manually rewrite their existing RON configs as Nix declarations. With ronix's fromRON, you could build something that reads the RON files from ~/.config/cosmic/ and ~/.local/share/cosmic/, parses them, and spits out the equivalent wayland.desktopManager.cosmic.* Nix config. That would make adoption a lot easier — bootstrap your declarative config from your current desktop state instead of starting from scratch.

Compatibility

  • Same __type convention, so cosmic-manager's lib/types.nix and lib/options.nix should work without changes
  • Nix flakes, supports x86_64-linux and aarch64-linux
  • MIT licensed

Happy to discuss and help with integration if there's interest!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions