mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-09 20:27:16 +00:00
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:
parent
20bcf9e946
commit
a4bff9749a
1 changed files with 16 additions and 3 deletions
19
flake.nix
19
flake.nix
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
perSystem = {pkgs, ...}: {
|
perSystem = {pkgs, ...}: {
|
||||||
# Provides the default formatter for 'nix fmt', which will format the
|
# 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
|
# changes to the behaviour of Nix, which now encourages wrappers for
|
||||||
# tree-wide formatting.
|
# tree-wide formatting.
|
||||||
formatter = pkgs.writeShellApplication {
|
formatter = pkgs.writeShellApplication {
|
||||||
|
|
@ -66,11 +66,15 @@
|
||||||
runtimeInputs = [
|
runtimeInputs = [
|
||||||
pkgs.alejandra
|
pkgs.alejandra
|
||||||
pkgs.fd
|
pkgs.fd
|
||||||
|
pkgs.deno
|
||||||
];
|
];
|
||||||
|
|
||||||
text = ''
|
text = ''
|
||||||
# Find Nix files in the tree and format them with Alejandra
|
# 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`
|
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
|
||||||
# or with `nix flake check`
|
# or with `nix flake check`
|
||||||
nix-fmt = pkgs.runCommand "nix-fmt-check" {nativeBuildInputs = [pkgs.alejandra];} ''
|
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
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue