diff --git a/flake.lock b/flake.lock index 380e3d7..fa9cd87 100644 --- a/flake.lock +++ b/flake.lock @@ -299,6 +299,21 @@ "type": "github" } }, + "flake-root_2": { + "locked": { + "lastModified": 1713493429, + "narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=", + "owner": "srid", + "repo": "flake-root", + "rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -1155,6 +1170,22 @@ "type": "github" } }, + "nixpkgs_15": { + "locked": { + "lastModified": 1708475490, + "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e74ca98a74bc7270d28838369593635a5db3260", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1698266953, @@ -1282,7 +1313,7 @@ "devshell": "devshell", "flake-compat": "flake-compat_4", "flake-parts": "flake-parts_3", - "flake-root": "flake-root", + "flake-root": "flake-root_2", "home-manager": "home-manager_2", "nix-darwin": "nix-darwin", "nixpkgs": [ @@ -2174,6 +2205,7 @@ "fast-syntax-highlighting": "fast-syntax-highlighting", "fioul": "fioul", "flake-parts": "flake-parts", + "flake-root": "flake-root", "glaurung": "glaurung", "gsm": "gsm", "home-manager": "home-manager", @@ -2244,6 +2276,7 @@ "roaming_proxy": "roaming_proxy", "rust-overlay": "rust-overlay_7", "simulationcraft": "simulationcraft", + "treefmt-nix": "treefmt-nix_2", "zsh-nix-shell": "zsh-nix-shell" } }, @@ -2667,6 +2700,24 @@ "type": "github" } }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": "nixpkgs_15" + }, + "locked": { + "lastModified": 1714058656, + "narHash": "sha256-Qv4RBm4LKuO4fNOfx9wl40W2rBbv5u5m+whxRYUMiaA=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "c6aaf729f34a36c445618580a9f95a48f5e4e03f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "utils": { "inputs": { "systems": "systems" diff --git a/flake.nix b/flake.nix index 902299c..2e8f567 100644 --- a/flake.nix +++ b/flake.nix @@ -43,6 +43,8 @@ attic.url = "github:zhaofengli/attic"; flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + flake-root.url = "github:srid/flake-root"; nix-index-database.url = "github:Mic92/nix-index-database"; nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; @@ -314,6 +316,8 @@ ./neovim/pkg.nix ./hostconfig ./templates + inputs.treefmt-nix.flakeModule + inputs.flake-root.flakeModule ]; perSystem = @@ -321,6 +325,7 @@ inputs', lib, system, + config, ... }: { @@ -338,6 +343,17 @@ ]; in lib.genAttrs names (name: inputs'.${name}.packages.${name}); + + formatter = config.treefmt.build.wrapper; + + treefmt.config = { + inherit (config.flake-root) projectRootFile; + + programs = { + nixfmt-rfc-style.enable = true; + statix.enable = true; + }; + }; }; flake =