flake: add a Markdown formatting check; add Deno to formatting wrapper

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I05593a413696ac3c6f03b2108f7ddd816a6a6964
This commit is contained in:
raf 2025-12-18 16:15:43 +03:00
commit a4bff9749a
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -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.<system>.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.<system>.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
'';
};
};