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

demo of nixpkgs-fmt 35ae8e6498e23d1b05091976acc0ae2a6f749096 #82932

Closed
wants to merge 1 commit into from

Conversation

zimbatm
Copy link
Member

@zimbatm zimbatm commented Mar 19, 2020

Motivation for this change

Get some feedback on the nixpkgs-fmt formatting engine. This is the output from the latest version of master.

Things done

Not intended to be merged

@7c6f434c
Copy link
Member

Is evaluation failure caused by a merge problem, or by the original revision being broken?

Random observation: switch-like «else if» chains are better off without ever-increasing indent level. Not sure what is the best criterion; maybe «else» with the body containing only an «if» (possibly with another «else») should be indented as a special «else+if» thing?

Copy link
Member Author

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

a quick pass of things that look not so great

Comment on lines +2 to +3
(import ./default.nix { }).overrideAttrs
(x: {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the original version was more readable.

@@ -7,7 +7,6 @@

outputs = { self }:
let

Copy link
Member Author

Choose a reason for hiding this comment

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

as a general rule nixpkgs-fmt doesn't collapse lines, but not 100% sure in this case

Comment on lines +32 to +33
}
);
Copy link
Member Author

Choose a reason for hiding this comment

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

these two should be collapsed. I think the rule is that if N containers are opened on the same line, then they should be closed on the same line as well

Comment on lines +26 to +29
if attrPath == [ ] then e
else
if e ? ${attr}
then attrByPath (tail attrPath) default e.${attr}
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure if it's worth the extra complexity to handle the else if case. the flat version looks nicer.

Copy link
Member

Choose a reason for hiding this comment

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

I agree this case would be better with else if but not worth it. I have commented on a larger example.

Comment on lines +161 to +162
fold (
n: a:
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure why n: a: was pushed to the next line here. to be investigated.

Comment on lines +51 to +53
if builtins.stringLength k == 1
then "-${k}"
else "--${k}"
Copy link
Member Author

Choose a reason for hiding this comment

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

this should be indented

Copy link
Member

Choose a reason for hiding this comment

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

You meant relative to k:, right?

}:
options:
options:
Copy link
Member Author

Choose a reason for hiding this comment

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

this should not be indented. function bodies stay on the same level.

Comment on lines +180 to +181
{ inherit (drv) name system meta; inherit outputs;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure why } was pushed to the next line

Comment on lines +99 to +104
if isList v
then noQuotes "[…]" v
else
if isAttrs v
then noQuotes "{…}" v
else v;
Copy link
Member Author

Choose a reason for hiding this comment

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

the original formatting was more readable to me

@zimbatm
Copy link
Member Author

zimbatm commented Mar 19, 2020

Is evaluation failure caused by a merge problem, or by the original revision being broken?

this is a bug in the rnix parser that needs to be fixed. It looks like it's not parsing URLs exactly the same way yet and https://git-ssb.celehner.com/%25n92DiQh7ietE%2BR%2BX%2FI403LQoyf2DtR3WQfCkDKlheQU%3D.sha256 is causing the problem.

@7c6f434c
Copy link
Member

https://git-ssb.celehner.com/%25n92DiQh7ietE%2BR%2BX%2FI403LQoyf2DtR3WQfCkDKlheQU%3D.sha256 is causing the problem

OK, so it is a good thing that the single-pass auto-quoting did not happen immediately…

Comment on lines +176 to +190
in
if isInt v then toString v
else
if isFloat v
then "~${toString v}"
else
if isString v
then ''"${libStr.escape [ ''"'' ] v}"''
else
if true == v
then "true"
else
if false == v
then "false"
else
Copy link
Member

Choose a reason for hiding this comment

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

This is where «else if» seems worth the complexity.

else
if isFloat v
then err "floats" v
else err "this value is" (toString v);
Copy link
Member

Choose a reason for hiding this comment

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

Storage space for some cheese 🧀

@veprbl veprbl removed the 6.topic: TeX Issues regarding texlive and TeX in general label Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants