feat: add treefmt
This commit is contained in:
parent
1b2224fac6
commit
37983b33a2
5 changed files with 71 additions and 1 deletions
23
flake.lock
generated
23
flake.lock
generated
|
|
@ -125,7 +125,8 @@
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
|
|
@ -144,6 +145,26 @@
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1760120816,
|
||||||
|
"narHash": "sha256-gq9rdocpmRZCwLS5vsHozwB6b5nrOBDNc2kkEaTXHfg=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "761ae7aff00907b607125b2f57338b74177697ed",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
treefmt-nix = {
|
||||||
|
url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
# for default.nix
|
# for default.nix
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
url = "github:edolstra/flake-compat?ref=master";
|
url = "github:edolstra/flake-compat?ref=master";
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,6 @@
|
||||||
./tests
|
./tests
|
||||||
|
|
||||||
./hydra.nix
|
./hydra.nix
|
||||||
|
./fmt.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
37
nix/fmt.nix
Normal file
37
nix/fmt.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{ inputs, ... }:
|
||||||
|
{
|
||||||
|
# load the flake module from upstream
|
||||||
|
imports = [ inputs.treefmt-nix.flakeModule ];
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{ self', lib, ... }:
|
||||||
|
{
|
||||||
|
treefmt = {
|
||||||
|
# repo root as project root
|
||||||
|
projectRoot = inputs.self;
|
||||||
|
|
||||||
|
# the formatters
|
||||||
|
programs = {
|
||||||
|
nixfmt.enable = true;
|
||||||
|
typos = {
|
||||||
|
enable = true;
|
||||||
|
configFile = "${inputs.self}/.typos.toml";
|
||||||
|
};
|
||||||
|
taplo = {
|
||||||
|
enable = true;
|
||||||
|
settings = lib.importTOML "${inputs.self}/taplo.toml";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
settings.formatter.rustfmt = {
|
||||||
|
command = "${lib.getExe' self'.packages.dev-toolchain "rustfmt"}";
|
||||||
|
includes = [ "**/*.rs" ];
|
||||||
|
options = [
|
||||||
|
"--unstable-features"
|
||||||
|
"--edition=2024"
|
||||||
|
"--config-path=${inputs.self}/rustfmt.toml"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
6
taplo.toml
Normal file
6
taplo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[formatting]
|
||||||
|
align_entries = true # Align entries vertically. Entries that have table headers, comments, or blank lines between them are not aligned.
|
||||||
|
|
||||||
|
reorder_arrays = true # Alphabetically reorder array values that are not separated by blank lines.
|
||||||
|
reorder_inline_tables = true # Alphabetically reorder inline tables.
|
||||||
|
reorder_keys = true # Alphabetically reorder keys that are not separated by blank lines.
|
||||||
Loading…
Add table
Reference in a new issue