Skip to content

lib.ron: init#440544

Open
HeitorAugustoLN wants to merge 2 commits intoNixOS:masterfrom
HeitorAugustoLN:ron-lib
Open

lib.ron: init#440544
HeitorAugustoLN wants to merge 2 commits intoNixOS:masterfrom
HeitorAugustoLN:ron-lib

Conversation

@HeitorAugustoLN
Copy link
Copy Markdown
Member

@HeitorAugustoLN HeitorAugustoLN commented Sep 5, 2025

Adds functions for parsing and generating RON (Rusty Object Notation) data.

Basically upstreaming some functions from cosmic-manager, for use in nixpkgs (system-wide COSMIC configurations, upstream some modules to home-manager, other modules, etc.), asked by some users in HeitorAugustoLN/cosmic-manager#34.

Option types for ron will be done in a follow-up PR

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 6.topic: lib The Nixpkgs function library labels Sep 5, 2025
@HeitorAugustoLN HeitorAugustoLN mentioned this pull request Sep 11, 2025
13 tasks
@qweered
Copy link
Copy Markdown
Contributor

qweered commented Sep 12, 2025

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 440544
Commit: ce59159cb49ffd3a51e1322c96b0bfefbb9fa5c6 (subsequent changes)
Merge: ea27617d2c18116cc99345583a6d9fd0c3f6fa74

Logs: https://github.com/qweered/nixpkgs-review-gha/actions/runs/17668045194


x86_64-linux

⏩ 2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
✅ 1 package built:
  • nixpkgs-manual

aarch64-linux

⏩ 2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
✅ 1 package built:
  • nixpkgs-manual

x86_64-darwin (sandbox = true)

✅ 1 package built:
  • nixpkgs-manual

aarch64-darwin (sandbox = true)

✅ 1 package built:
  • nixpkgs-manual

Copy link
Copy Markdown
Contributor

@qweered qweered left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically following the successful run of nixpkgs-review.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Sep 12, 2025
@JohnRTitor JohnRTitor requested a review from roberth September 24, 2025 12:33
Copy link
Copy Markdown
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review. I've had a look at the overall design, but very little at the implementation.

Testing

This is a lot of intricate code, so it needs tests.
You can add them in lib/tests.
A basic test strategy would be to use lib/tests/misc.nix, but for really good coverage, you could generate pairs of RON and expected parsed Nix values with a Rust program. (rnix, or just go via JSON).

Documentation

Format lgtm overall, but the new sublibrary needs to be added in doc/doc-support/lib-function-docs.nix.
Not sure if we have something for an introductory section to lay out the in-Nix format, but I guess toRON could just refer to fromRON to achieve something similar.

- Maps: `{ _type = "ron-map"; value = [{ key = ...; value = ...; }, ...]; }`
- Named structs: `{ _type = "ron-named-struct"; name = "..."; value = { ... }; }`
- Tuples: `{ _type = "ron-tuple"; value = [...]; }`
- Raw values: `{ _type = "ron-raw"; value = "..."; }`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs introduction, but should it even be generated by the parser?

Copy link
Copy Markdown
Member Author

@HeitorAugustoLN HeitorAugustoLN Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I improved the documentation for the raw type to cover its uses.

Regarding your question, the parser generates raw values to prevent data loss on high-precision floats and to handle unsupported syntax without crashing.

The raw type is also useful when generating RON with toRON, as it allows a user to inject a pre-formatted raw string. This offers more flexibility for complex values or for syntax the builder doesn't support (which currently doesn't happen).

Similarly to:

nixpkgs/lib/generators.nix

Lines 885 to 888 in 7e246f7

mkLuaInline = expr: {
_type = "lua-inline";
inherit expr;
};

For me, it seems like a valuable feature. I'm open to other ideas if you have a different approach in mind.

@nixpkgs-ci nixpkgs-ci bot added the 8.has: documentation This PR adds or changes documentation label Sep 25, 2025
@HeitorAugustoLN HeitorAugustoLN force-pushed the ron-lib branch 3 times, most recently from 537a5c9 to 493e8d2 Compare September 27, 2025 15:50
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 7, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 9, 2025
@GetPsyched
Copy link
Copy Markdown
Member

Thanks for the effort to upstream this, @HeitorAugustoLN!

I had a small request (can be done in a followup PR): Could this new generator also be added to pkgs.formats as pkgs.formats.ron?


Is there anything pending on this PR? I'd like to use this feature soon.

@HeitorAugustoLN
Copy link
Copy Markdown
Member Author

I had a small request (can be done in a followup PR): Could this new generator also be added to pkgs.formats as pkgs.formats.ron?

It is already done in #442207

@GetPsyched
Copy link
Copy Markdown
Member

Nice! Thanks!

HeitorAugustoLN and others added 2 commits December 7, 2025 16:55
Adds functions for parsing and generating RON (Rusty Object Notation) data.
@cguentherTUChemnitz
Copy link
Copy Markdown

It would be really nice, if something of the merge process would unblock this. This is the starting point of a merge-request series to bring in nixos home-manager automated theming of cattpuccin for cosmic desktop environment. I am really missing this, since every other component is properly themed already.

@caniko
Copy link
Copy Markdown
Contributor

caniko commented Mar 8, 2026

I too think it should be in nixpkgs! I made ronix without knowing this was in progress! Anyway I think ronix can still be used for mapping ron files to nix configurations, very useful for migration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants