From a393654c3b007244d34797dd9235f1e726ffe321 Mon Sep 17 00:00:00 2001 From: Chris Scutcher Date: Tue, 7 Feb 2023 15:51:33 +0000 Subject: [PATCH] style: Define formatter in flake to allow `nix fmt` Noticed this was an option to codify the agreed style/pattern auto-normalise discussed in [#143] [#143]: https://github.com/nix-community/disko/pull/143 --- flake.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flake.nix b/flake.nix index a82ee58..6749318 100644 --- a/flake.nix +++ b/flake.nix @@ -57,5 +57,22 @@ ''; in nixosTests // { inherit shellcheck; }); + formatter = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + pkgs.writeShellApplication { + name = "normalise_nix"; + runtimeInputs = with pkgs; [ + nixpkgs-fmt + statix + ]; + text = '' + set -o xtrace + nixpkgs-fmt "$@" + statix fix "$@" + ''; + } + ); }; }