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 default nix formatter and its corresponding Github action #190

Closed
wants to merge 2 commits into from

Conversation

drupol
Copy link
Collaborator

@drupol drupol commented Dec 27, 2022

This PR:

@drupol drupol force-pushed the ci/use-alejandra branch 2 times, most recently from 5ed2f6d to 8ec55db Compare December 31, 2022 08:35
@drupol
Copy link
Collaborator Author

drupol commented Jan 14, 2023

@jtojnar WDYT about this?

Copy link
Member

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

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

I like this in principle and Alejandra feels closest to the ideal but there are still some cases where I feel like the formatting style hinders reading style where one is quickly scanning the code top-down (without moving much focus to the right).

I have wanted to play with it some more and argue for style changes where necessary upstream but have not found the time yet.

nixpkgs,
utils,
}:
# For each supported platform,
Copy link
Member

@jtojnar jtojnar Jan 14, 2023

Choose a reason for hiding this comment

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

Misaligned. Edit: Reported in kamadorueda/alejandra#372 (comment)

}:
# For each supported platform,
utils.lib.eachDefaultSystem (
system: let
Copy link
Member

Choose a reason for hiding this comment

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

Moving let to the same line as parameters is IMO inconsistent with indenting function bodies and makes visually scanning code harder (especially when the parameter list is long).

Comment on lines 2 to +4
pkgs:

# Overlay to be passed as packageOverrides to Nixpkgs’s generic PHP builder:

final:
prev:

let
final: prev: let
Copy link
Member

@jtojnar jtojnar Jan 14, 2023

Choose a reason for hiding this comment

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

This is also weird, some arguments on single line and other not. Edit: reported in kamadorueda/alejandra#375

Comment on lines -70 to 83
callPackage =
cpFn:
cpArgs:

callPackage = cpFn: cpArgs:
prev.callPackage
Copy link
Member

Choose a reason for hiding this comment

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

Here again the arguments are moved away from the function body’s level, making it harder to notice it is a function body when scanning the code.

Comment on lines 62 to -96
prev.callPackage
cpFn
Copy link
Member

Choose a reason for hiding this comment

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

function
argument1
arg2

to me looks too much like a list of equal items so I have started indenting the arguments:

function
  argument1
  argument2

Will need to do more testing to see how it plays out in practice.

@drupol
Copy link
Collaborator Author

drupol commented Jan 14, 2023

What we could do, is to use nixpkgs-fmt instead.

I saw many controversial things about alejandra.

IMHO, I like alejandra, but there are things I do not like in it as well, and I would not mind replacing it with something else.

pkgs/lib.nix Show resolved Hide resolved
@drupol
Copy link
Collaborator Author

drupol commented Feb 17, 2023

Closing the PR until further notice.

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.

2 participants