forked from lix-project/nix-eval-jobs
Add treefmt
And use it in place of editorconfig/nixpkgs-fmt checks
This commit is contained in:
parent
9482b5ab3e
commit
516fdc8f6c
|
@ -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
|
|
28
flake.nix
28
flake.nix
|
@ -8,6 +8,7 @@
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
drvArgs = { srcDir = self; };
|
drvArgs = { srcDir = self; };
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
|
@ -26,25 +27,18 @@
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
editorconfig = pkgs.runCommand "editorconfig-check"
|
treefmt = stdenv.mkDerivation {
|
||||||
{
|
name = "treefmt-check";
|
||||||
nativeBuildInputs = [
|
src = self;
|
||||||
pkgs.editorconfig-checker
|
nativeBuildInputs = devShells.default.nativeBuildInputs;
|
||||||
];
|
dontConfigure = true;
|
||||||
} ''
|
|
||||||
editorconfig-checker ${self}
|
buildPhase = ''
|
||||||
touch $out
|
env HOME=$(mktemp -d) treefmt --fail-on-change
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nixpkgs-fmt = pkgs.runCommand "fmt-check"
|
installPhase = "touch $out";
|
||||||
{
|
};
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.nixpkgs-fmt
|
|
||||||
];
|
|
||||||
} ''
|
|
||||||
nixpkgs-fmt --check .
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
build = mkVariant pkgs.nix;
|
build = mkVariant pkgs.nix;
|
||||||
build-unstable = mkVariant pkgs.nixUnstable;
|
build-unstable = mkVariant pkgs.nixUnstable;
|
||||||
|
|
|
@ -26,8 +26,7 @@ in
|
||||||
|
|
||||||
nativeBuildInputs = old.nativeBuildInputs ++ [
|
nativeBuildInputs = old.nativeBuildInputs ++ [
|
||||||
|
|
||||||
pkgs.editorconfig-checker
|
pkgs.treefmt
|
||||||
|
|
||||||
pkgs.nixpkgs-fmt
|
pkgs.nixpkgs-fmt
|
||||||
|
|
||||||
(pkgs.python3.withPackages (ps: [
|
(pkgs.python3.withPackages (ps: [
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{ pkgs ? import (builtins.getFlake (toString ./.)).inputs.nixpkgs { }
|
||||||
pkgs ? import (builtins.getFlake (toString ./.)).inputs.nixpkgs { }
|
, system ? pkgs.system
|
||||||
, system ? pkgs.system
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
3
treefmt.toml
Normal file
3
treefmt.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[formatter.nix]
|
||||||
|
command = "nixpkgs-fmt"
|
||||||
|
includes = ["*.nix"]
|
Loading…
Reference in a new issue