From c2eac1a161f7325c9dc5f8e47a2ee9ea454ccd36 Mon Sep 17 00:00:00 2001 From: zimbatm <zimbatm@zimbatm.com> Date: Wed, 12 Apr 2023 10:15:26 +0200 Subject: [PATCH] treefmt: flatten the config By importing the config on the treefmt module level, it makes the config more flat, and also compatible with non-flake-parts users. --- flake.nix | 3 +- treefmt.nix | 86 +++++++++++++++++++++++++---------------------------- 2 files changed, 43 insertions(+), 46 deletions(-) diff --git a/flake.nix b/flake.nix index 963058f..1adf6f0 100644 --- a/flake.nix +++ b/flake.nix @@ -60,9 +60,10 @@ inputs.treefmt-nix.flakeModule ./effect.nix ./shell.nix - ./treefmt.nix ]; + perSystem.treefmt.imports = [ ./treefmt.nix ]; + flake.nixosConfigurations = let inherit (inputs.nixpkgs.lib) nixosSystem; diff --git a/treefmt.nix b/treefmt.nix index bfa4a97..c8bd0be 100644 --- a/treefmt.nix +++ b/treefmt.nix @@ -1,54 +1,50 @@ -{ - perSystem = { pkgs, ... }: { - treefmt = { - # Used to find the project root - projectRootFile = "flake.lock"; +{ pkgs, ... }: { + # Used to find the project root + projectRootFile = "flake.lock"; - programs.hclfmt.enable = true; + programs.hclfmt.enable = true; - programs.prettier.enable = true; + programs.prettier.enable = true; - settings.formatter = { - nix = { - command = "sh"; - options = [ - "-eucx" - '' - for i in "$@"; do - ${pkgs.lib.getExe pkgs.statix} fix "$i" - done + settings.formatter = { + nix = { + command = "sh"; + options = [ + "-eucx" + '' + for i in "$@"; do + ${pkgs.lib.getExe pkgs.statix} fix "$i" + done - ${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@" - '' - "--" - ]; - includes = [ "*.nix" ]; - excludes = [ - "nix/sources.nix" - # vendored from external source - "build02/packages-with-update-script.nix" - ]; - }; + ${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@" + '' + "--" + ]; + includes = [ "*.nix" ]; + excludes = [ + "nix/sources.nix" + # vendored from external source + "build02/packages-with-update-script.nix" + ]; + }; - prettier = { - excludes = [ - "secrets.yaml" - ]; - }; + prettier = { + excludes = [ + "secrets.yaml" + ]; + }; - python = { - command = "sh"; - options = [ - "-eucx" - '' - ${pkgs.lib.getExe pkgs.ruff} --fix "$@" - ${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@" - '' - "--" # this argument is ignored by bash - ]; - includes = [ "*.py" ]; - }; - }; + python = { + command = "sh"; + options = [ + "-eucx" + '' + ${pkgs.lib.getExe pkgs.ruff} --fix "$@" + ${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@" + '' + "--" # this argument is ignored by bash + ]; + includes = [ "*.py" ]; }; }; }