Add treefmt formatter (nix fmt + flake check gate)

This commit is contained in:
Berwn
2026-06-16 16:46:14 +07:00
parent 3302b70485
commit cf0d796bee
3 changed files with 81 additions and 14 deletions
+27 -13
View File
@@ -1,6 +1,8 @@
{
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/25.11.tar.gz";
inputs.nixpkgs.follows = "clan-core/nixpkgs";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
outputs =
{
@@ -31,24 +33,36 @@
"age-plugin-fido2-hmac"
];
};
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: clan-core.inputs.nixpkgs.legacyPackages.${system};
treefmtFor = system: inputs.treefmt-nix.lib.evalModule (pkgsFor system) ./fmt.nix;
in
{
inherit (clan.config) nixosConfigurations nixosModules clanInternals;
clan = clan.config;
# `nix fmt` and the `nix flake check` formatting gate.
formatter = forAllSystems (system: (treefmtFor system).config.build.wrapper);
checks = forAllSystems (system: {
formatting = (treefmtFor system).config.build.check self;
});
# Add the Clan cli tool to the dev shell.
# Use "nix develop" to enter the dev shell.
devShells =
nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
]
(system: {
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
packages = [ clan-core.packages.${system}.clan-cli ];
};
});
devShells = forAllSystems (system: {
default = (pkgsFor system).mkShell {
packages = [
clan-core.packages.${system}.clan-cli
(treefmtFor system).config.build.wrapper
];
};
});
};
}