Add treefmt

And use it in place of editorconfig/nixpkgs-fmt checks
This commit is contained in:
adisbladis 2022-04-26 20:48:39 +12:00
parent 9482b5ab3e
commit 516fdc8f6c
5 changed files with 18 additions and 47 deletions

View file

@ -1,24 +0,0 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{cc,hh,hpp,pl,pm,sh,t}]
indent_style = space
intend_size = 4
[Makefile]
indent_style = tab
[*.nix]
indent_style = space
indent_size = 2
# Match diffs, avoid to trim trailing whitespace
[*.{diff,patch}]
trim_trailing_whitespace = false

View file

@ -8,6 +8,7 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) stdenv;
drvArgs = { srcDir = self; };
in
rec {
@ -26,25 +27,18 @@
in
{
editorconfig = pkgs.runCommand "editorconfig-check"
{
nativeBuildInputs = [
pkgs.editorconfig-checker
];
} ''
editorconfig-checker ${self}
touch $out
treefmt = stdenv.mkDerivation {
name = "treefmt-check";
src = self;
nativeBuildInputs = devShells.default.nativeBuildInputs;
dontConfigure = true;
buildPhase = ''
env HOME=$(mktemp -d) treefmt --fail-on-change
'';
nixpkgs-fmt = pkgs.runCommand "fmt-check"
{
nativeBuildInputs = [
pkgs.nixpkgs-fmt
];
} ''
nixpkgs-fmt --check .
touch $out
'';
installPhase = "touch $out";
};
build = mkVariant pkgs.nix;
build-unstable = mkVariant pkgs.nixUnstable;

View file

@ -26,8 +26,7 @@ in
nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.editorconfig-checker
pkgs.treefmt
pkgs.nixpkgs-fmt
(pkgs.python3.withPackages (ps: [

View file

@ -1,6 +1,5 @@
{
pkgs ? import (builtins.getFlake (toString ./.)).inputs.nixpkgs { }
, system ? pkgs.system
{ pkgs ? import (builtins.getFlake (toString ./.)).inputs.nixpkgs { }
, system ? pkgs.system
}:
{

3
treefmt.toml Normal file
View file

@ -0,0 +1,3 @@
[formatter.nix]
command = "nixpkgs-fmt"
includes = ["*.nix"]