diff --git a/flake.nix b/flake.nix index e7ee847..3b34261 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,12 @@ deploy-rs.url = "github:serokell/deploy-rs"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; flake-utils.url = "github:numtide/flake-utils"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + + pre-commit-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; disko = { url = "github:nix-community/disko"; @@ -58,7 +64,6 @@ ./shell.nix ./utils ./machines - ] // (flake-utils.lib.eachDefaultSystem (system: { - formatter = nixpkgs.legacyPackages.${system}.nixfmt; - })); + ./formatter.nix + ]; } diff --git a/formatter.nix b/formatter.nix new file mode 100644 index 0000000..8696b53 --- /dev/null +++ b/formatter.nix @@ -0,0 +1,9 @@ +{ nixpkgs, treefmt-nix, flake-utils, ...}: flake-utils.lib.eachDefaultSystem (system: +let + pkgs = nixpkgs.legacyPackages.${system}; + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; +in +{ + formatter = treefmtEval.config.build.wrapper; +} +) diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..e6da195 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,4 @@ +{...}: { + projectRootFile = "flake.nix"; + programs.alejandra.enable = true; +}