Skip to content

nix: Full reformat according to RFC 166 #7161

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 2 commits into from
May 20, 2025
Merged

Conversation

tolbrino
Copy link
Contributor

@tolbrino tolbrino commented May 20, 2025

This pull request refactors multiple Nix files to improve code readability and maintainability by adopting a consistent formatting style. The changes primarily involve restructuring function arguments, reformatting lists, and improving indentation. Additionally, some minor logic adjustments and cleanups were made to streamline the code.

General Refactoring and Formatting:

  • Updated function argument definitions across all modified files to use a consistent inline object format instead of a mix of destructured and inline styles. This change improves readability and aligns with common Nix conventions. (nix/cargo-bench.nix - [1] nix/ciShell.nix - [2] nix/ciTestShell.nix - [3] nix/devShell.nix - [4] nix/docker-builder.nix - [5] nix/mkShell.nix - [6] nix/rust-builder.nix - [7] nix/rust-package.nix - [8] nix/testShell.nix - [9]

Logic Adjustments:

  • Simplified conditional expressions and list concatenations to reduce unnecessary complexity and improve clarity. For example:
    • Adjusted the handling of useRustNightly in nix/mkShell.nix and nix/rust-builder.nix to improve readability. ([[1]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-752d0fd4b5e4e869e73b3d6595c90ab223165d9d05b313ccd3f6da6558ea788dL3-R23), [[2]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-e6d1fdf69580149a5e1ca677e574a38ec6801a9ef0030e8a87ff0cda25fe3d2bL59-R70))
    • Streamlined the logic for setting up Darwin-specific build inputs in nix/rust-package.nix. ([[1]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-ddb90233e19f19be4cba88e3a2de97470eef8a4628cbb184f1d2d40df3b443b6L47-R50), [[2]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-ddb90233e19f19be4cba88e3a2de97470eef8a4628cbb184f1d2d40df3b443b6L93-R118))

Consistent Formatting of Lists and Attributes:

  • Reformatted long lists and attribute sets to place each item on a separate line for better readability. This change is particularly noticeable in files like nix/docker-builder.nix, nix/rust-package.nix, and nix/rust-builder.nix. ([[1]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-d713e6aeb3aba5d4d7830fb2b36f236ef03336c65c7b85f56c66f7aa84e58577L1-R21), [[2]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-ddb90233e19f19be4cba88e3a2de97470eef8a4628cbb184f1d2d40df3b443b6L93-R118), [[3]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-e6d1fdf69580149a5e1ca677e574a38ec6801a9ef0030e8a87ff0cda25fe3d2bL69-R88))

Improvements to Shell Hooks:

  • Refactored shell hook logic in nix/testShell.nix to improve readability and ensure consistent formatting for multi-line strings. ([nix/testShell.nixL19-R29](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-8c24d44470b8ff447664f6c19883951182e3ad0ac0539462dd5ecafd9a832996L19-R29))

Cleanup of Redundant Code:

  • Removed unnecessary parentheses and redundant attributes in several files, such as nix/rust-builder.nix and nix/rust-package.nix, to streamline the code. ([[1]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-e6d1fdf69580149a5e1ca677e574a38ec6801a9ef0030e8a87ff0cda25fe3d2bL42-R53), [[2]](https://github.com/hoprnet/hoprnet/pull/7161/files#diff-ddb90233e19f19be4cba88e3a2de97470eef8a4628cbb184f1d2d40df3b443b6L154-R172))

@tolbrino tolbrino added this to the 3.0.0 milestone May 20, 2025
@tolbrino tolbrino requested a review from a team May 20, 2025 09:06
@tolbrino tolbrino self-assigned this May 20, 2025
Copy link
Contributor

coderabbitai bot commented May 20, 2025

📝 Walkthrough

Walkthrough

This set of changes focuses on reformatting and restructuring various Nix expression files for improved readability and stylistic consistency. The updates include adjustments to argument lists, attribute set formatting, list indentation, and shell script string formatting. No modifications are made to logic, functionality, exported entities, or control flow; all changes are purely stylistic.

Changes

File(s) Change Summary
flake.nix Reformatted attribute sets, lists, and shell script strings; unified use of multi-line and single-line styles; updated formatter tool; no logic changes.
nix/cargo-bench.nix Changed function parameter destructuring and argument merging style; reformatted for clarity; no logic changes.
nix/ciShell.nix, nix/ciTestShell.nix, nix/devShell.nix, nix/testShell.nix Reformatted function arguments, attribute sets, and shell hook string concatenation; improved indentation and punctuation; no changes to logic or exported entities.
nix/docker-builder.nix Reformatted argument list and list concatenation for contents; improved indentation; no logic changes.
nix/mkShell.nix Reformatted argument list, assignments, and list constructions; improved indentation and style; no logic changes.
nix/rust-builder.nix Reformatted function arguments, imports, conditional logic, and attribute sets; improved indentation and style; no logic changes.
nix/rust-package.nix Reformatted argument list, attribute sets, lists, and shell script strings; improved indentation and style; no logic changes.

Sequence Diagram(s)

No sequence diagrams generated, as the changes are purely stylistic and do not introduce or modify control flow or feature logic.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9ad491 and 48d4d65.

📒 Files selected for processing (10)
  • flake.nix (19 hunks)
  • nix/cargo-bench.nix (1 hunks)
  • nix/ciShell.nix (2 hunks)
  • nix/ciTestShell.nix (2 hunks)
  • nix/devShell.nix (2 hunks)
  • nix/docker-builder.nix (1 hunks)
  • nix/mkShell.nix (1 hunks)
  • nix/rust-builder.nix (5 hunks)
  • nix/rust-package.nix (7 hunks)
  • nix/testShell.nix (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: hoprd / docker
  • GitHub Check: hopli / docker
  • GitHub Check: tests-smoke-hopli
  • GitHub Check: tests-unit-nightly
  • GitHub Check: zizmor
  • GitHub Check: Linter
  • GitHub Check: tests-unit
🔇 Additional comments (39)
nix/docker-builder.nix (2)

1-8: Improved argument list formatting

The multi-line argument list with trailing commas improves readability and makes future modifications easier. This formatting change aligns well with the RFC 166 guidelines.


11-21: Well-structured content list

The multi-line formatting of the package list provides better readability by clearly separating each package dependency, making it easier to maintain in the future.

nix/mkShell.nix (4)

1-10: Improved function parameter structure

The multi-line parameter list with trailing commas enhances readability and aligns with the RFC 166 formatting guidelines.


13-19: Cleaner conditional expression formatting

The restructured if-then-else expression for rustToolchain improves readability by properly indenting each branch.


21-46: Well-structured package list

The multi-line formatting of minimumPackages significantly improves readability by clearly organizing each package on its own line, with proper sections for formatting tools.


54-60: Better library path construction

The multi-line structure for LD_LIBRARY_PATH construction makes it easier to see which libraries are included and how conditional inclusions are applied.

nix/cargo-bench.nix (3)

1-3: Improved input parameter structure

The restructured input parameter improves clarity by separating mkCargoDerivation into its own parameter.


5-9: Enhanced argument pattern matching

The multi-line format for the attribute pattern matching enhances readability while maintaining the same destructuring functionality.


15-25: Clearer function call structure

The reformatted mkCargoDerivation call with multi-line attribute merging improves readability while preserving the exact same functionality.

nix/rust-builder.nix (10)

1-12: Improved input parameter structure

The multi-line format with trailing commas for function parameters significantly improves readability and maintainability.


13-16: Better let-binding structure

The nested let-binding is now properly formatted with clear indentation, making the code structure more apparent.


21-25: Well-structured overlay list

The multi-line format for overlays makes each overlay clearly visible and easier to maintain.


30-36: Cleaner conditional logic formatting

The restructured conditional expression with proper indentation improves readability.


40-43: Consistent overlay formatting

The multi-line format for overlays matches the style used earlier in the file, maintaining consistency.


53-53: Improved function definition

The single-line function definition has been properly formatted with consistent spacing.


68-70: Better nesting for toolchain override

The multi-line format for the toolchain override improves readability by clearly separating the configuration options.


79-79: Improved environment variable expression

The string interpolation for environment variable naming is now properly formatted.


84-89: Cleaner conditional structure

The if-then-else expression for static build environment is now properly formatted with consistent indentation and braces.


97-126: Well-structured callPackage function

The complete restructuring of the callPackage function with proper indentation, multi-line parameter lists, and clear attribute set merging significantly improves readability while maintaining identical functionality.

flake.nix (1)

1-867: Formatting updates comply with RFC 166 and maintain existing semantics.

All modifications in this file are purely stylistic—adjusting indentation, alignments, multi-line lists, attribute set formatting, and shell-script string blocks—for improved readability and consistency. I confirm no logic, control-flow, or exported-entity changes.

nix/devShell.nix (1)

1-24: Consistent argument destructuring and import formatting.

The reformatted argument list and the multi-line import of ./testShell.nix follow the same style guidelines applied across the Nix files in this PR. No behavioral changes introduced.

nix/ciShell.nix (1)

1-39: Purely stylistic reformat of ciShell.

The transition to a standard attribute-set pattern for arguments and the multi-line mkShell call improve clarity without altering functionality. Approved.

nix/testShell.nix (1)

1-50: Multiline string and record update formatting only.

Adjustments to finalShellHook concatenation and the mkShell invocation are formatting-only and consistent with RFC 166. No logic changed.

nix/ciTestShell.nix (1)

1-24: Reformatted argument list and import merge.

The changes to argument destructuring and the ./testShell.nix merge expression are stylistic, matching the rest of the PR. Functionally equivalent.

nix/rust-package.nix (15)

1-28: Consistent, comma-separated argument list improves readability

The transition to a trailing-comma, comma-separated function argument list adheres to RFC 166 conventions and greatly enhances maintainability without changing any semantics.


48-54: Consolidated darwinSuffixSalt, targetSuffixSalt, and setup hook definition

Refactoring these assignments into single-line expressions and inlining the makeSetupHook call sharpens focus on intent while preserving existing behavior.


66-68: Compact inline conditional definitions for pnameSuffix and pnameDeps

The one-liner if expressions yield the same suffix logic in fewer lines, increasing clarity and matching adjacent patterns.


69-71: Streamlined version computation

Using lib.strings.concatStringsSep with take 3 in a concise, multi-line form maintains functionality while reducing boilerplate.


78-85: Expanded darwinBuildInputs into a multi-line list

Explicitly bracketing and indenting the list of macOS frameworks follows the project’s style guide and keeps the original contents intact.


88-89: Refactored darwinNativeBuildInputs conditional

The inline if-else expression clearly communicates when the Darwin hook should be included, without affecting logic.


91-102: Enhanced readability for buildInputs conditional branches

Separating the isStatic and non-static branches with with pkgs.pkgsStatic; and with pkgs; plus bracketed lists improves legibility, while semantics remain unchanged.


108-119: Clean concatenation for nativeBuildInputs and buildInputs in sharedArgsBase

Listing each input in bracketed arrays and then merging via ++ ensures consistent formatting. Both nativeBuildInputs and buildInputs concatenations preserve prior dependency order and behavior.


131-139: Flattened sharedArgs conditional for tests

Merging additional test-specific attributes into sharedArgsBase with a compact // { … } block removes unnecessary braces around the outer expression and aligns with surrounding styles.


163-170: Refactored defaultArgs cargoArtifacts merging

Using a parenthesized, multi-line merge of sharedArgs with overrides for pname and src condenses the definition without affecting its output.


172-172: Concise args selection with inline conditional

The single-line if buildDocs then … else … merge succinctly chooses between documentation and default arguments, matching the file’s new stylistic conventions.


190-193: Normalized builder invocation formatting

Breaking out the builder function call into multiple lines with explicit inherit src postInstall; merges clarifies the final derivation inputs without modifying behavior.


195-201: Aligned indentation for preConfigure script

Consistent indentation of the heredoc-style shell block enhances readability and parallels other Nix expressions in the repo.


203-209: Aligned indentation for preFixup script

Using lib.optionalString with a neatly indented script block keeps the cross-compilation patch logic intact and in line with the updated formatting guidelines.


210-211: Clean closing braces and parentheses

Final alignment of the closing } and ) completes the refactoring, ensuring the file respects consistent indentation and trailing-comma conventions.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tolbrino tolbrino marked this pull request as ready for review May 20, 2025 09:06
@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 09:07
@tolbrino tolbrino enabled auto-merge May 20, 2025 09:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 10 changed files in this pull request and generated no comments.

Files not reviewed (9)
  • nix/cargo-bench.nix: Language not supported
  • nix/ciShell.nix: Language not supported
  • nix/ciTestShell.nix: Language not supported
  • nix/devShell.nix: Language not supported
  • nix/docker-builder.nix: Language not supported
  • nix/mkShell.nix: Language not supported
  • nix/rust-builder.nix: Language not supported
  • nix/rust-package.nix: Language not supported
  • nix/testShell.nix: Language not supported

@github-actions github-actions bot added the toolchain Developer and product happiness label May 20, 2025
@tolbrino tolbrino added this pull request to the merge queue May 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 20, 2025
@Teebor-Choka Teebor-Choka merged commit cab18f3 into master May 20, 2025
29 of 31 checks passed
@Teebor-Choka Teebor-Choka deleted the tb/202505-nix-reformat branch May 20, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolchain Developer and product happiness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants