aboutsummaryrefslogtreecommitdiff
path: root/home-manager/tests/meta/formatting.nix
blob: 2d5800c53cd3e70fa7888373831d2698a2033667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ config, lib, pkgs, ... }:

with lib;

let

  pinnedNixpkgs = builtins.fetchTarball {
    url =
      "https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz";
    sha256 = "1g8c2w0661qn89ajp44znmwfmghbbiygvdzq0rzlvlpdiz28v6gy";
  };

  pinnedPkgs = import pinnedNixpkgs { };

in {
  config = {
    nmt.script = ''
      PATH="${with pinnedPkgs; lib.makeBinPath [ findutils nixfmt ]}:$PATH"
      cd ${../..}
      if ! ${pkgs.runtimeShell} format -c; then
        fail "${''
        Expected source code to be formatted with nixfmt but it was not.
        This error can be resolved by running the './format' in the project root directory.''}"
      fi
    '';
  };
}