Skip to content

Commit

Permalink
flake: add formatting check
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAShelf committed Sep 28, 2024
1 parent 69cd776 commit cef3aef
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
inherit inputs;
specialArgs = {inherit lib;};
} {
# provide overridable systems
# https://github.com/nix-systems/nix-systems
# Allow users to bring their own systems.
# «https://github.com/nix-systems/nix-systems»
systems = import inputs.systems;
imports = [
./flake/apps.nix
Expand Down Expand Up @@ -62,14 +62,28 @@
pkgs,
...
}: {
formatter = pkgs.alejandra;
devShells = {
default = self'.devShells.lsp;
nvim-nix = pkgs.mkShell {packages = [config.packages.nix];};
lsp = pkgs.mkShell {
packages = with pkgs; [nil statix deadnix alejandra];
};
};

# Provide the default formatter. `nix fmt` in project root
# will format available files with the correct formatter.
# P.S: Please do not format with nixfmt! It messes with many
# syntax elements and results in unreadable code.
formatter = pkgs.alejandra;

# Check if codebase is properly formatted.
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
# or with `nix flake check`
checks = {
nix-fmt = pkgs.runCommand "nix-fmt-check" {nativeBuildInputs = [pkgs.alejandra];} ''
alejandra --check ${self} < /dev/null | tee $out
'';
};
};
};

Expand Down

0 comments on commit cef3aef

Please sign in to comment.