build(flake): Add treefmt
This only adds this as nix module. So running `nix fmt` will now format all files under the repo root. If you want to run this as non-nix user feel free to take a look at the generated `treefmt.toml`.
This commit is contained in:
parent
03f8eda241
commit
1b8a33c919
23
flake.lock
23
flake.lock
|
@ -174,7 +174,8 @@
|
|||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"systems": "systems"
|
||||
"systems": "systems",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
|
@ -247,6 +248,26 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1708335038,
|
||||
"narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
44
flake.nix
44
flake.nix
|
@ -16,7 +16,6 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# and the Lesser GNU General Public License along with this program.
|
||||
# If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
description = "A rust crate used to generate multi-language apis for your
|
||||
application";
|
||||
|
@ -29,6 +28,13 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
systems = {
|
||||
url = "github:nix-systems/default";
|
||||
};
|
||||
|
@ -64,11 +70,13 @@
|
|||
};
|
||||
};
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
crane,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
ebnf2pdf,
|
||||
treefmt-nix,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
|
@ -112,18 +120,52 @@
|
|||
doCheck = true;
|
||||
inherit nativeBuildInputs buildInputs;
|
||||
};
|
||||
treefmtEval = treefmt-nix.lib.evalModule pkgs (
|
||||
{pkgs, ...}: {
|
||||
# Used to find the project root
|
||||
projectRootFile = "flake.nix";
|
||||
|
||||
programs = {
|
||||
alejandra.enable = true;
|
||||
rustfmt.enable = true;
|
||||
clang-format.enable = true;
|
||||
mdformat.enable = true;
|
||||
shfmt = {
|
||||
enable = true;
|
||||
indent_size = 4;
|
||||
};
|
||||
shellcheck.enable = true;
|
||||
};
|
||||
|
||||
settings.formatter = {
|
||||
clang-format = {
|
||||
options = ["--style" "GNU"];
|
||||
};
|
||||
rustfmt = {
|
||||
# also add the Trixy files
|
||||
includes = ["*.tri"];
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
in {
|
||||
checks.default = craneBuild;
|
||||
packages = {
|
||||
default = craneBuild;
|
||||
};
|
||||
|
||||
formatter = treefmtEval.config.build.wrapper;
|
||||
checks = {
|
||||
formatting = treefmtEval.config.build.check self;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
alejandra
|
||||
|
||||
cocogitto
|
||||
licensure
|
||||
treefmt
|
||||
|
||||
rust
|
||||
cargo-edit
|
||||
|
|
Reference in New Issue