dev: Use treefmt-nix for CI autoformat check

This commit is contained in:
Sridhar Ratnakumar 2023-07-10 21:30:06 -04:00 committed by Sridhar Ratnakumar
parent 687ea2adb5
commit 197fc1c4d0
2 changed files with 45 additions and 4 deletions

View File

@ -82,12 +82,47 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1680945546,
"narHash": "sha256-8FuaH5t/aVi/pR1XxnF0qi4WwMYC+YxlfdsA0V+TEuQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d9f759f2ea8d265d974a6e1259bd510ac5844c5d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"flake-root": "flake-root",
"mission-control": "mission-control",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1688916551,
"narHash": "sha256-YsGzTjtYwJ7j8TTIjo0cImycGAvUT1UXq2sCZ8Vu0Wc=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "3fadb6baac68068dc0196f35d3e092bf316d4409",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},

View File

@ -4,6 +4,7 @@
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
mission-control.url = "github:Platonic-Systems/mission-control";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
@ -11,8 +12,15 @@
imports = [
inputs.flake-root.flakeModule
inputs.mission-control.flakeModule
inputs.treefmt-nix.flakeModule
];
perSystem = { pkgs, lib, config, ... }: {
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
};
};
mission-control.scripts = {
ex = {
description = "Run example";
@ -24,9 +32,7 @@
};
fmt = {
description = "Format all Nix files";
exec = ''
${lib.getExe pkgs.fd} -e nix | xargs ${lib.getExe pkgs.nixpkgs-fmt}
'';
exec = config.treefmt.build.wrapper;
};
};
devShells.default = pkgs.mkShell {