Add Nix Flake Check and Nix Fmt to Devenv Hooks
Automatically integrate standard nix flake check and nix fmt. Specifically, when treefmt or git-hooks are configured in a project.
We won't add nix flake check as it takes too long, commit hooks should be fast!
We should be able to add nix fmt.
Sorry, yes it was meant to devenv.
I don't understand.
This issue was intended to be opened in cachix/devenv, since the git-hooks.nix and treefmt-nix Flake modules already add the formatters and checks individually. However, problems arise when they are defined at the devenv level such as:
{
inputs = {
devenv.url = "github:cachix/devenv";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks.url = "github:cachix/git-hooks.nix";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs =
inputs@{
self,
devenv,
git-hooks,
flake-parts,
treefmt-nix,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
devenv.flakeModule
treefmt-nix.flakeModule
git-hooks.flakeModule
];
perSystem =
{
config,
pkgs,
system,
...
}:
{
# We need to set the treefmt wrapper to the one from the devenv shell
treefmt.build.wrapper = config.devenv.shells.default.treefmt.config.build.wrapper;
devenv.shells.default.treefmt.enable = true;
};
};
}
Here's an example of how I fixed it on my side: https://github.com/shikanime-studio/devlib/blob/cc2d111e461b4fa4b413f3d14ddffa50de65e007/modules/flake/default.nix