From 4ccd0d9981b38abb02d0cf9cf5cc4c40f0ee5e24 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 13 Jan 2025 14:41:21 -0600 Subject: [PATCH] add formatter check --- lib/default.nix | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 63c27d9..b1a7b78 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -43,6 +43,23 @@ let }) flakes ); + evalTreeFmt = + pkgs: + (treefmt-nix.lib.evalModule pkgs ( + { ... }: + { + projectRootFile = "flake.nix"; + # don't warn me about missing formatters + settings.excludes = [ + # likely to be nnl lockfiles + "pkgs/**/lock.json" + "hosts/**/secrets.yaml" + ]; + settings.on-unmatched = "debug"; + programs = "prettier|nixfmt" |> listify |> enableAttrs; + } + )); + oizysFlake = { templates = { dev = { @@ -84,25 +101,12 @@ let inherit inputs lib self; system = pkgs.system; } + // { + formatter = (evalTreeFmt pkgs).config.build.check self; + } ); + formatter = forAllSystems (pkgs: (evalTreeFmt pkgs).config.build.wrapper); # formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); - formatter = forAllSystems ( - pkgs: - (treefmt-nix.lib.evalModule pkgs ( - { ... }: - { - projectRootFile = "flake.nix"; - # don't warn me about missing formatters - settings.excludes = [ - # likely to be nnl lockfiles - "pkgs/**/lock.json" - "hosts/**/secrets.yaml" - ]; - settings.on-unmatched = "debug"; - programs = "prettier|nixfmt" |> listify |> enableAttrs; - } - )).config.build.wrapper - ); }; in {