From b31197716ed31f9bcbafdcfd1c4b5ff6fd344856 Mon Sep 17 00:00:00 2001 From: Yoann Beaugnon Date: Sat, 3 Feb 2024 19:08:54 +0100 Subject: [PATCH] Add treefmt-nix with nixpkgs-fmt for formatting --- flake.lock | 23 ++++++++++++++++++++++- flake.nix | 12 +++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index eadee78..12a41a0 100644 --- a/flake.lock +++ b/flake.lock @@ -55,7 +55,28 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706462057, + "narHash": "sha256-7dG1D4iqqt0bEbBqUWk6lZiSqqwwAO0Hd1L5opVyhNM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "c6153c2a3ff4c38d231e3ae99af29b87f1df5901", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index eeb4d70..56c0a1d 100644 --- a/flake.nix +++ b/flake.nix @@ -4,16 +4,26 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix.url = "github:numtide/treefmt-nix"; # Formatter + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = inputs @ { self, nixpkgs, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.treefmt-nix.flakeModule + ]; systems = [ "x86_64-linux" ]; flake = { }; - perSystem = { config, ... }: { }; + perSystem = { config, ... }: { + treefmt = { + projectRootFile = "flake.nix"; + programs.nixpkgs-fmt.enable = true; + }; + }; }; }