From f0269198ec0ee49d58ab0e3abc77c351cfef95f6 Mon Sep 17 00:00:00 2001 From: Robin Quintero Date: Mon, 24 Jun 2024 13:40:28 -0500 Subject: [PATCH] feat(back): #1332 add check flag to nixfmt - Run check only in CI, locally it will format the code - Update docs to show the use of nixfmt instead of Alejandra Signed-off-by: Robin Quintero --- docs/src/api/builtins/format.md | 2 +- src/args/format-nix/entrypoint.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/api/builtins/format.md b/docs/src/api/builtins/format.md index 7d5e929c..0e902981 100644 --- a/docs/src/api/builtins/format.md +++ b/docs/src/api/builtins/format.md @@ -80,7 +80,7 @@ Example: ## formatNix Ensure that Nix code is formatted -according to [Alejandra](https://github.com/kamadorueda/alejandra). +according to [nixfmt](https://github.com/NixOS/nixfmt). Types: diff --git a/src/args/format-nix/entrypoint.sh b/src/args/format-nix/entrypoint.sh index adef9ea6..62885f1e 100644 --- a/src/args/format-nix/entrypoint.sh +++ b/src/args/format-nix/entrypoint.sh @@ -2,11 +2,15 @@ function main { source __argTargets__/template local targets + local args=() info Formatting Nix code \ + && if running_in_ci_cd_provider; then + args+=(--check) + fi \ && for target in "${targets[@]}"; do info Formatting "${target}" \ - && if ! nixfmt "${target}"; then + && if ! nixfmt "${args[@]}" "${target}"; then info Source code was formated, the job will fail \ && error Failing as promised... fi \