From 2e7c521d70ac562ec0e5dae4df0f1538bcb5ef54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kopa=C5=84ski?= Date: Tue, 6 Feb 2024 16:21:41 +0100 Subject: [PATCH] Check for leftover white space Agda stdlib team recommends to run [fix-whitespace](https://github.com/agda/agda-stdlib/blob/master/HACKING.md#how-to-enforce-whitespace-policies) in order to get rid of unnecessary white space characters. I've added this tool to the nix dev shell, as well as formed a check that will be can be run with `nix flake check` command. As of now this is entirely opt-in as this check is not enabled in (and thus won't fail) the CI. --- fix-whitespace.yaml | 13 +++++++++++++ flake.nix | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 fix-whitespace.yaml diff --git a/fix-whitespace.yaml b/fix-whitespace.yaml new file mode 100644 index 0000000..2ca3b5a --- /dev/null +++ b/fix-whitespace.yaml @@ -0,0 +1,13 @@ +included-dirs: + - src + +included-files: + - "*.agda" + - "*.md" + - "*.org" + - "*.nix" + +excluded-dirs: + - .git + - .direnv + - result diff --git a/flake.nix b/flake.nix index ff3b77e..67268aa 100644 --- a/flake.nix +++ b/flake.nix @@ -21,10 +21,22 @@ agdaWithStandardLibrary = pkgs.agda.withPackages (_: [ standard-library ]); in { - devShell = pkgs.mkShell { + checks.whitespace = pkgs.stdenvNoCC.mkDerivation { + name = "check-whitespace"; + dontBuild = true; + src = ./.; + doCheck = true; + checkPhase = '' + ${pkgs.haskellPackages.fix-whitespace}/bin/fix-whitespace --check + ''; + installPhase = ''mkdir "$out"''; + }; + + devShells.default = pkgs.mkShell { buildInputs = [ agdaWithStandardLibrary pkgs.graphviz + pkgs.haskellPackages.fix-whitespace ]; };