Skip to content

Commit 11c37f0

Browse files
committed
treefmt: add nightly rustfmt via fenix with formatting config
This commit adds a rustfmt formatting config with some nightly options enabled that greatly improve the formatter. Some of the highlights include wrapping comments & strings, organizing imports, and formatting imports to have 1 import per line (which really helps with diffs). Due to all these formatting goodies, the diff is quite massive but nothing functionally changed.
1 parent cdab17b commit 11c37f0

78 files changed

Lines changed: 2540 additions & 1820 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rustfmt.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
condense_wildcard_suffixes = true
2+
doc_comment_code_block_width = 100
3+
edition = "2024"
4+
enum_discrim_align_threshold = 60
5+
float_literal_trailing_zero = "Always"
6+
force_multiline_blocks = true
7+
format_code_in_doc_comments = true
8+
format_macro_matchers = true
9+
format_strings = true
10+
group_imports = "StdExternalCrate"
11+
hex_literal_case = "Upper"
12+
imports_granularity = "Crate"
13+
imports_layout = "Vertical"
14+
inline_attribute_width = 60
15+
match_block_trailing_comma = true
16+
max_width = 100
17+
newline_style = "Unix"
18+
normalize_comments = true
19+
normalize_doc_attributes = true
20+
overflow_delimited_expr = true
21+
struct_field_align_threshold = 60
22+
unstable_features = true
23+
use_field_init_shorthand = true
24+
use_try_shorthand = true
25+
wrap_comments = true

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[workspace]
2-
32
members = [ "subprojects/hydra-builder", "subprojects/hydra-queue-runner", "subprojects/crates/*" ]
43
resolver = "2"
54

65
[workspace.package]
6+
edition = "2024"
77
rust-version = "1.91.0"
88
version = "0.1.0"
99

flake.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
flake = false;
1616
};
1717

18+
inputs.fenix = {
19+
url = "github:nix-community/fenix";
20+
inputs.nixpkgs.follows = "nixpkgs";
21+
};
22+
1823
inputs.treefmt-nix = {
1924
url = "github:numtide/treefmt-nix";
2025
inputs.nixpkgs.follows = "nixpkgs";
@@ -26,6 +31,7 @@
2631
nixpkgs,
2732
nix,
2833
nix-eval-jobs,
34+
fenix,
2935
treefmt-nix,
3036
...
3137
}:
@@ -66,18 +72,20 @@
6672
});
6773

6874
treefmtConfig =
75+
system:
6976
{ ... }:
7077
{
7178
projectRootFile = "flake.lock";
7279
programs.rustfmt = {
7380
enable = true;
74-
edition = "2024";
81+
package = fenix.packages.${system}.latest.rustfmt;
7582
};
7683
programs.nixfmt.enable = true;
7784
programs.taplo.enable = true;
7885
};
7986

80-
treefmtEval = system: treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} treefmtConfig;
87+
treefmtEval =
88+
system: treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} (treefmtConfig system);
8189
in
8290
rec {
8391

@@ -174,6 +182,7 @@
174182
hydra-linters
175183
hydra-queue-runner
176184
;
185+
nightly-rustfmt = fenix.packages.${system}.latest.rustfmt;
177186
};
178187
});
179188

packaging/dev-shell.nix

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
hydra-manual,
66
hydra-linters,
77
hydra-queue-runner,
8+
nightly-rustfmt,
89
}:
910

1011
let
@@ -40,14 +41,12 @@ hydra.overrideAttrs (
4041
src = null;
4142
sourceRoot = null;
4243

43-
nativeBuildInputs =
44-
collectInputs "nativeBuildInputs"
45-
++ (with pkgs; [
46-
clippy
47-
nixfmt
48-
rustfmt
49-
taplo
50-
]);
44+
nativeBuildInputs = collectInputs "nativeBuildInputs" ++ [
45+
pkgs.clippy
46+
pkgs.nixfmt
47+
nightly-rustfmt
48+
pkgs.taplo
49+
];
5150
buildInputs = collectInputs "buildInputs";
5251

5352
inherit (hydra-tests) OPENLDAP_ROOT;

subprojects/crates/binary-cache/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "binary-cache"
33
version = "0.1.0"
4-
edition = "2024"
4+
edition.workspace = true
55
license = "LGPL-2.1-only"
66
rust-version.workspace = true
77

subprojects/crates/binary-cache/examples/download_file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2828

2929
let stats = client.s3_stats();
3030
tracing::info!(
31-
"stats: put={}, put_bytes={}, put_time_ms={}, get={}, get_bytes={}, get_time_ms={}, head={}",
31+
"stats: put={}, put_bytes={}, put_time_ms={}, get={}, get_bytes={}, get_time_ms={}, \
32+
head={}",
3233
stats.put,
3334
stats.put_bytes,
3435
stats.put_time_ms,

subprojects/crates/binary-cache/examples/query_missing_paths.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2626

2727
let stats = client.s3_stats();
2828
tracing::info!(
29-
"stats: put={}, put_bytes={}, put_time_ms={}, get={}, get_bytes={}, get_time_ms={}, head={}",
29+
"stats: put={}, put_bytes={}, put_time_ms={}, get={}, get_bytes={}, get_time_ms={}, \
30+
head={}",
3031
stats.put,
3132
stats.put_bytes,
3233
stats.put_time_ms,

subprojects/crates/binary-cache/examples/simple_presigned.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
use binary_cache::{
2+
PresignedUploadClient,
3+
S3BinaryCacheClient,
4+
path_to_narinfo,
5+
};
16
use futures::stream::StreamExt as _;
2-
3-
use binary_cache::{PresignedUploadClient, S3BinaryCacheClient, path_to_narinfo};
47
use harmonia_utils_hash::fmt::CommonHash as _;
58
use nix_utils::BaseStore as _;
69

subprojects/crates/binary-cache/examples/upload_logs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1717

1818
let stats = client.s3_stats();
1919
tracing::info!(
20-
"stats: put={}, put_bytes={}, put_time_ms={}, get={}, get_bytes={}, get_time_ms={}, head={}",
20+
"stats: put={}, put_bytes={}, put_time_ms={}, get={}, get_bytes={}, get_time_ms={}, \
21+
head={}",
2122
stats.put,
2223
stats.put_bytes,
2324
stats.put_time_ms,

0 commit comments

Comments
 (0)