27 lines
694 B
Nix
Raw Permalink Normal View History

{
# Exposes a formatter output and a check that uses the same formatter on
# a file in this example directory.
description = "A minimal formatter and checks example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
{
formatter.${system} = pkgs.nixfmt;
checks.${system}.formats = pkgs.runCommand "formatter-check" { } ''
cp ${./sample.nix} ./sample.nix
${pkgs.nixfmt}/bin/nixfmt ./sample.nix >/dev/null
grep -q 'greeting = "hello";' ./sample.nix
echo ok > "$out"
'';
};
}