Skip to content

Commit

Permalink
Configure treefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
wagdav committed Nov 19, 2024
1 parent 689af11 commit fcd976b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
23 changes: 22 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 10 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, disko, flake-compat, nixpkgs, nixos-generators, nixos-hardware, cachix-deploy }@attrs:
outputs = { self, disko, flake-compat, nixpkgs, nixos-generators, nixos-hardware, cachix-deploy, treefmt-nix }@attrs:
let
system = "x86_64-linux";

Expand All @@ -38,6 +42,8 @@

dashboard-linter = pkgs.callPackage ./modules/grafana/dashboard-linter.nix { };

treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;

in
{
nixosConfigurations = {
Expand All @@ -48,6 +54,8 @@
rp4 = mkMachine "aarch64-linux" [ ./host-rp4.nix ];
};

formatter.${system} = treefmtEval.config.build.wrapper;

apps.${system} = {
mqtt-dash-listen = {
type = "app";
Expand Down Expand Up @@ -90,15 +98,7 @@
};

checks.${system} = with pkgs; {
nixpkgs-fmt = runCommand "nixpkgs-fmt"
{
buildInputs = [ nixpkgs-fmt ];
src = self;
}
''
mkdir $out
nixpkgs-fmt --check "$src"
'';
formatting = treefmtEval.config.build.check self;

markdownlint = runCommand "mdl"
{
Expand All @@ -117,16 +117,6 @@
mkdir $out
shellcheck --shell bash ${./scripts}/*
'';

yamllint = runCommand "yamllint"
{
buildInputs = [ actionlint yamllint ];
}
''
mkdir $out
yamllint --strict ${./.github/workflows}
# actionlint ${./.github/workflows}/*.yml
'';
};
};
}
3 changes: 0 additions & 3 deletions scripts/fmt.sh

This file was deleted.

7 changes: 7 additions & 0 deletions treefmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ pkgs, ... }:
{
projectRootFile = "flake.nix";
programs.actionlint.enable = true;
programs.nixpkgs-fmt.enable = true;
programs.shellcheck.enable = true;
}

0 comments on commit fcd976b

Please sign in to comment.