From 0c5caf0a9d46a66862c7382c77a5e3f7b2c9ed34 Mon Sep 17 00:00:00 2001 From: Miran Bastaja Date: Mon, 5 Aug 2024 10:55:47 +0200 Subject: Use nix to configure treefmt --- flake.lock | 23 ++++++++++++++++++++++- flake.nix | 24 +++++++++++++++++------- treefmt.nix | 5 +++++ treefmt.toml | 6 ------ 4 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 treefmt.nix delete mode 100644 treefmt.toml diff --git a/flake.lock b/flake.lock index 387e0b3..1a79bec 100644 --- a/flake.lock +++ b/flake.lock @@ -382,7 +382,8 @@ "rust-overlay": "rust-overlay", "snippets-ls": "snippets-ls", "sops-nix": "sops-nix", - "sorre-website": "sorre-website" + "sorre-website": "sorre-website", + "treefmt-nix": "treefmt-nix_2" } }, "rust-overlay": { @@ -521,6 +522,26 @@ "repo": "treefmt-nix", "type": "github" } + }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722330636, + "narHash": "sha256-uru7JzOa33YlSRwf9sfXpJG+UAV+bnBEYMjrzKrQZFw=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "768acdb06968e53aa1ee8de207fd955335c754b7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8324f07..361061c 100644 --- a/flake.nix +++ b/flake.nix @@ -37,31 +37,41 @@ url = "github:nlewo/comin"; inputs.nixpkgs.follows = "nixpkgs"; }; + + # development stuff + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { + self, nixpkgs, futils, nix-on-droid, + treefmt-nix, ... }@inputs: futils.lib.eachSystem ( system: let - pkgs = inputs.nixpkgs.legacyPackages.${system}; + pkgs = import inputs.nixpkgs { inherit system; }; + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; in { devShells.default = futils.lib.minimalMkShell pkgs { - buildInputs = with pkgs; [ - git + packages = with pkgs; [ + gitMinimal sops - - # Formatting - treefmt - nixfmt-rfc-style ]; }; + + formatter = treefmtEval.config.build.wrapper; + checks = { + formatting = treefmtEval.config.build.check self; + }; } ) // { diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..970592a --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,5 @@ +{ ... }: +{ + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; +} diff --git a/treefmt.toml b/treefmt.toml deleted file mode 100644 index 13bf952..0000000 --- a/treefmt.toml +++ /dev/null @@ -1,6 +0,0 @@ -[global] -excludes = ["secrets/*", ".*ignore", ".git*", "*.lock"] - -[formatter.nix] -command = "nixfmt" -includes = [ "*.nix" ] -- cgit v1.3.1