Add treefmt formatter (nix fmt + flake check gate)
This commit is contained in:
Generated
+22
-1
@@ -166,7 +166,8 @@
|
|||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"clan-core",
|
"clan-core",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
],
|
||||||
|
"treefmt-nix": "treefmt-nix_2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sops-nix": {
|
"sops-nix": {
|
||||||
@@ -225,6 +226,26 @@
|
|||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1780220602,
|
||||||
|
"narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "db947814a175b7ca6ded66e21383d938df01c227",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/25.11.tar.gz";
|
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/25.11.tar.gz";
|
||||||
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
||||||
|
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{
|
||||||
@@ -31,24 +33,36 @@
|
|||||||
"age-plugin-fido2-hmac"
|
"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
|
in
|
||||||
{
|
{
|
||||||
inherit (clan.config) nixosConfigurations nixosModules clanInternals;
|
inherit (clan.config) nixosConfigurations nixosModules clanInternals;
|
||||||
clan = clan.config;
|
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.
|
# Add the Clan cli tool to the dev shell.
|
||||||
# Use "nix develop" to enter the dev shell.
|
# Use "nix develop" to enter the dev shell.
|
||||||
devShells =
|
devShells = forAllSystems (system: {
|
||||||
nixpkgs.lib.genAttrs
|
default = (pkgsFor system).mkShell {
|
||||||
[
|
packages = [
|
||||||
"x86_64-linux"
|
clan-core.packages.${system}.clan-cli
|
||||||
"aarch64-linux"
|
(treefmtFor system).config.build.wrapper
|
||||||
"aarch64-darwin"
|
];
|
||||||
"x86_64-darwin"
|
};
|
||||||
]
|
});
|
||||||
(system: {
|
|
||||||
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
|
|
||||||
packages = [ clan-core.packages.${system}.clan-cli ];
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# treefmt config, evaluated per-system in flake.nix and exposed as
|
||||||
|
# `nix fmt` (the formatter) plus a `nix flake check` formatting gate.
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
|
||||||
|
programs = {
|
||||||
|
nixfmt.enable = true;
|
||||||
|
prettier.enable = true;
|
||||||
|
yamlfmt.enable = true;
|
||||||
|
shfmt.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
on-unmatched = "fatal";
|
||||||
|
global.excludes = [
|
||||||
|
# Secrets and clan-managed state — never reformat.
|
||||||
|
"sops/*"
|
||||||
|
"vars/*"
|
||||||
|
"inventory.json"
|
||||||
|
|
||||||
|
# Generated — don't reformat (regeneration would churn the diff).
|
||||||
|
"*facter.json"
|
||||||
|
|
||||||
|
# No formatter, or reformatting would corrupt them.
|
||||||
|
"*.zone" # Knot zone files
|
||||||
|
"flake.lock"
|
||||||
|
".envrc"
|
||||||
|
".gitignore"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user