Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to render quoteless strings in gvariant #1397

Closed
wants to merge 1 commit into from

Conversation

mogorman
Copy link

@mogorman mogorman commented Jul 21, 2020

Description

Some of the values in my dconf settings ini file need to be quoteless strings,
@mb true for example when rendered with quotes does not set the value for bluetooth correctly as its a string and not a maybe type boolean set to true.
but if pass mkRawString "@mb true" in it writes the correct key=@mb true to the file.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

    • Added myself and the module files to .github/CODEOWNERS.

in dconf some things are easily represented by a string but must not
be a quoted string for example value `@mb true` describes a type maybe boolean and its value is true. currently home-manager is rendering this as '@mb true' which is stored in dconf but does not operate properly. using mkRawString "@mb true" does work as it writes a quoteless string in the ini
@mogorman
Copy link
Author

I guess a possible better feature would be able to render variables in this same format, but this was what i needed to fix my small issue.

@rycee rycee closed this in 83301ca Jul 24, 2020
@rycee
Copy link
Member

rycee commented Jul 24, 2020

I added support for maybe instead: https://rycee.gitlab.io/home-manager/index.html#sec-option-types

@mogorman
Copy link
Author

mogorman commented Jul 24, 2020

thanks solves that one. i havent tried yet but what about a more complex data type like

[<(uint32 2, <('Quincy, Massachusetts, United States of America', '', false, [(0.73745182558084266, -1.2392233966166404)], [(0.73754877513013228, -1.2399264065126976)])>)>]

@rycee
Copy link
Member

rycee commented Jul 24, 2020

Variants are not supported yet but it shouldn't be a problem to add support for them.

@mogorman
Copy link
Author

i think rawstrings or extraConfig is a good way to sidestep issues like that though.

@rycee
Copy link
Member

rycee commented Jul 24, 2020

I'm not a fan of raw strings in this case. It would mean admitting defeat in ever having this data type being used for anything beside serializing to text. Which kind of bypasses the entire need for having a data type in the first place.

I assume you are wanting to load stuff into dconf? If so and you want to work with raw GVariant text then I would recommend simply creating an activation block that runs, e.g., dconf write.

@mogorman
Copy link
Author

i have been playing with impermanence from nix-community, so it is my goal to have all my dconf state defined. those complex blobs and the @mb where the only things not converted correctly. so i have them special cased now with my own mkRawString. I would love to be able to do it type for type, but I understand that is not a priority thats why i would think extraConfig might be right stop gap procedure. but setup is working for me now, so thank you.

malte-v pushed a commit to malte-v/home-manager that referenced this pull request Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants