-
Notifications
You must be signed in to change notification settings - Fork 92
Added --compact arg to rc2nix.py for outputting nested Nix attr sets #534
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
base: trunk
Are you sure you want to change the base?
Conversation
A very much needed change! |
I'm starting to think 'compact' is the wrong term here. Should I change it to 'pretty'? Other suggestions welcome |
@c0d3m0nky |
'format' feels too vague The other option I'm thinking is --nested Why is coming up with good names always the hardest part? 🥲 |
The official Nix formatting RFC uses |
Changed it to -n|--nested-format |
So I found a bug in rc2nix.py but I'm not sure I should include it in this PR or wait and make a followup PR. For shortcuts when multiple or none are set it outputs invalid values like {
"Window Minimize" = [
"Meta+Down"
"Meta+PgDown,Meta+PgDown,Minimize Window"
];
"Window Move" = "none,,Move Window";
} I have confirmed it happens with the HEAD of this repo too, I did not accidentally introduce this. Should I include the fix in this PR? |
Turned out to be an extremely simple fix, so I just included it. |
For me the way rc2nix.py outputs it's Nix conversion is unreadable. Not a criticism, just an accommodation I need, so I made it an option
When executing rc2nix.py with no arguments the output remains unchanged
But with the -n|--nested-format argument it will nest the output, attr sets and lists with a single child remain in-line
I also introduced a minor change that will only quote keys when necessary using this regular expression
^[a-z_][\w_-]*?$
If the key begins with a letter or underscore, and the rest of the characters are all alphanumeric, underscore, or dash, it will not unnecessarily quote the key. I'm actually not 100% sure those are all the valid characters, but by making it inclusive it is fail-safe
Additional bugfixes: