From a4bff9749a73cf662fbdbcc6d7a4d22ba6316200 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 18 Dec 2025 16:15:43 +0300 Subject: [PATCH] flake: add a Markdown formatting check; add Deno to formatting wrapper Signed-off-by: NotAShelf Change-Id: I05593a413696ac3c6f03b2108f7ddd816a6a6964 --- flake.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 31e8d0f1..9a7fc438 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,7 @@ perSystem = {pkgs, ...}: { # Provides the default formatter for 'nix fmt', which will format the - # entire tree with Alejandra. The wrapper script is necessary due to + # entire Nix source with Alejandra. The wrapper script is necessary due to # changes to the behaviour of Nix, which now encourages wrappers for # tree-wide formatting. formatter = pkgs.writeShellApplication { @@ -66,11 +66,15 @@ runtimeInputs = [ pkgs.alejandra pkgs.fd + pkgs.deno ]; text = '' # Find Nix files in the tree and format them with Alejandra - fd "$@" -t f -e nix -x alejandra -q '{}' + fd "$@" -t f -e nix -x nixfmt -q '{}' + + # Same for Markdown files, but with deno + fd "$@" -t f -e md -x deno fmt '{}' ''; }; @@ -81,7 +85,16 @@ # This can be initiated with `nix build .#checks..nix-fmt` # or with `nix flake check` nix-fmt = pkgs.runCommand "nix-fmt-check" {nativeBuildInputs = [pkgs.alejandra];} '' - alejandra --check ${self} < /dev/null | tee $out + alejandra --check ${self} < /dev/null + touch $out + ''; + + # Check if Markdown sources are properly formatted + # This can be initiated with `nix build .#checks..md-fmt` + # or with `nix flake check` + md-fmt = pkgs.runCommand "md-fmt-check" {nativeBuildInputs = [pkgs.deno];} '' + deno fmt --check ${self} --ext md < /dev/null + touch $out ''; }; };