Skip to content

flake: Add meson formatter #13350

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

Merged
merged 1 commit into from
Jun 13, 2025
Merged

flake: Add meson formatter #13350

merged 1 commit into from
Jun 13, 2025

Conversation

xokdvium
Copy link
Contributor

Motivation

This adds a meson.format file that mostly mirrors the projects meson style and a pre-commit hook to enforce this style. Some low-diff files are formatted.

Our meson files are already formatted mostly in a way that is consistent with what meson format
can be configured to enforce. The added meson.format style is the best one I could come up with
to produce the least diff.

By adding a formatter for meson files we are reducing the chore of:

  • Manually enforcing a consistent meson style.
  • Sorting files by hand.

There are some cases where meson format might introduce more code churn (e.g. not always formatting files multiline). This can be manually worked around by adding a placeholder comment. Not sure yet if it's worth it. The diff for formatting everything is already quite small and I don't expect that meson files experience a lot of code churn with backports.

Context

Formatter docs are available at https://mesonbuild.com/Commands.html#format.

cc @roberth for pre-commit stuff and @Ericson2314 wrt to meson.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This adds a meson.format file that mostly mirrors the projects
meson style and a pre-commit hook to enforce this style.
Some low-diff files are formatted.
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Jun 11, 2025
@Ericson2314
Copy link
Member

This can be manually worked around by adding a placeholder comment.

I think that does sound worth it to me. I am tempted to make an upstream issue about this sort of thing also.

done
''}";
excludes = [
# We haven't applied formatting to these files yet
Copy link
Member

Choose a reason for hiding this comment

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

for build system changes I am tempted to just do them in a follow up pull request. I don't think we have many pull requests touching them.

@Mic92 Mic92 merged commit a1fe09d into NixOS:master Jun 13, 2025
12 checks passed
@xokdvium xokdvium deleted the meson-format branch June 13, 2025 16:18
@roberth roberth added the backports ignored Seen but not applied label Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backports ignored Seen but not applied with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants