From d53a45f6b3219462cd67a65c8ede5c69f835c23c Mon Sep 17 00:00:00 2001 From: Artur Manuel Date: Sat, 5 Oct 2024 00:58:42 +0100 Subject: [PATCH] feat: add treefmt-nix --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 8 +++++++- nix/treefmt.nix | 8 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 nix/treefmt.nix diff --git a/flake.lock b/flake.lock index 2579dd11acd..d22175d7b46 100644 --- a/flake.lock +++ b/flake.lock @@ -201,6 +201,7 @@ "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": "nixpkgs", "systems": "systems", + "treefmt-nix": "treefmt-nix", "xdph": "xdph" } }, @@ -219,6 +220,26 @@ "type": "github" } }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727984844, + "narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "xdph": { "inputs": { "hyprland-protocols": "hyprland-protocols_2", diff --git a/flake.nix b/flake.nix index ee5af6a1b09..82ccacb0996 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,11 @@ inputs.hyprutils.follows = "hyprutils"; inputs.hyprwayland-scanner.follows = "hyprwayland-scanner"; }; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs @ { @@ -82,6 +87,7 @@ hyprland-extras ]; }); + treefmtEval = eachSystem (system: inputs.treefmt-nix.lib.evalModule pkgsFor.${system} ./nix/treefmt.nix); in { overlays = import ./nix/overlays.nix {inherit self lib inputs;}; @@ -122,7 +128,7 @@ }; }); - formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra); + formatter = eachSystem (system: treefmtEval.${system}.config.build.wrapper); nixosModules.default = import ./nix/module.nix inputs; homeManagerModules.default = import ./nix/hm-module.nix self; diff --git a/nix/treefmt.nix b/nix/treefmt.nix new file mode 100644 index 00000000000..9a57042236d --- /dev/null +++ b/nix/treefmt.nix @@ -0,0 +1,8 @@ +_: { + projectRootFile = "flake.nix"; + programs = { + alejandra.enable = true; + clang-format.enable = true; + }; + settings.global.excludes = ["!*.cpp" "!*.nix"]; +}