feat(flake): add treefmt for formatting all files
This commit is contained in:
22
flake.nix
22
flake.nix
@@ -6,6 +6,11 @@
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
crane.url = "github:ipetkov/crane";
|
||||
|
||||
rust-overlay = {
|
||||
@@ -17,11 +22,16 @@
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-parts,
|
||||
treefmt-nix,
|
||||
crane,
|
||||
rust-overlay,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
imports = [
|
||||
treefmt-nix.flakeModule
|
||||
];
|
||||
|
||||
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
|
||||
|
||||
perSystem = {system, ...}: let
|
||||
@@ -71,7 +81,13 @@
|
||||
};
|
||||
|
||||
# Formatter for nix files, available through 'nix fmt'
|
||||
formatter = pkgs.alejandra;
|
||||
treefmt = {
|
||||
programs.alejandra.enable = true;
|
||||
programs.rustfmt = {
|
||||
enable = true;
|
||||
edition = (builtins.fromTOML (builtins.readFile "${src}/Cargo.toml")).package.edition;
|
||||
};
|
||||
};
|
||||
|
||||
# Your custom packages
|
||||
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
||||
@@ -86,10 +102,6 @@
|
||||
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
||||
cargoClippyExtraArgs = "-- --deny warnings";
|
||||
};
|
||||
|
||||
fmt = craneLib.cargoFmt {
|
||||
inherit src buildInputs nativeBuildInputs;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user