From eaede2faaf0350bc2f7a110924f656b1a0474585 Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Tue, 24 Sep 2024 17:27:17 -0300 Subject: [PATCH] chore(formatting): replace treefmt-nix with treefmt for formatting - Removed treefmt-nix dependency and all related configurations. - Added a new treefmt.toml file for formatting with nixfmt and ruff. - Updated .gitignore to ignore result files and .direnv. - Removed treefmt.nix and adjusted flake.nix accordingly. - Updated development shell to include nixfmt-rfc-style. --- .envrc | 1 + .gitignore | 2 ++ flake.lock | 23 +---------------------- flake.nix | 13 ++----------- treefmt.nix | 9 --------- treefmt.toml | 21 +++++++++++++++++++++ 6 files changed, 27 insertions(+), 42 deletions(-) create mode 100644 .envrc create mode 100644 .gitignore delete mode 100644 treefmt.nix create mode 100644 treefmt.toml diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cdd60a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result* +.direnv diff --git a/flake.lock b/flake.lock index 6d7e7fa..26431cc 100644 --- a/flake.lock +++ b/flake.lock @@ -18,28 +18,7 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "treefmt-nix": "treefmt-nix" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1726734507, - "narHash": "sha256-VUH5O5AcOSxb0uL/m34dDkxFKP6WLQ6y4I1B4+N3L2w=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "ee41a466c2255a3abe6bc50fc6be927cdee57a9f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 3652f3c..1aeb542 100644 --- a/flake.nix +++ b/flake.nix @@ -3,10 +3,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - treefmt-nix = { - url = "github:numtide/treefmt-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = @@ -25,17 +21,12 @@ inputs.nixpkgs.lib.genAttrs supportedSystems ( system: function inputs.nixpkgs.legacyPackages.${system} ); - - treefmtEval = forAllSystems (pkgs: inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix); in { - checks = forAllSystems (pkgs: { - formatting = treefmtEval.${pkgs.system}.config.build.check inputs.self; - }); - devShells = forAllSystems (pkgs: { default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ + nixfmt-rfc-style ruff (python3.withPackages ( pyPkgs: with pyPkgs; [ @@ -48,7 +39,7 @@ }; }); - formatter = forAllSystems (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); + formatter = forAllSystems (pkgs: pkgs.treefmt); homeManagerModules.betterfox = import ./modules; diff --git a/treefmt.nix b/treefmt.nix deleted file mode 100644 index c4248a5..0000000 --- a/treefmt.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - projectRootFile = "treefmt.nix"; - - settings.globals.excludes = [ "./autogen/**" ]; - - programs.nixfmt.enable = true; - programs.ruff-check.enable = true; - programs.ruff-format.enable = true; -} diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..05d083e --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,21 @@ +[global] +excludes = ["autogen"] + +[formatter.nixfmt] +command = "nixfmt" +includes = ["*.nix"] + +[formatter.ruff-check] +command = "ruff" +options = ["check", "--fix"] +includes = ["*.py", "*.pyi"] + +[formatter.ruff-format] +command = "ruff" +options = ["format"] +includes = ["*.py", "*.pyi"] + +[formatter.ruff-organize-imports] +command = "ruff" +options = ["check", "--select", "I", "--fix"] +includes = ["*.py", "*.pyi"]