aboutsummaryrefslogtreecommitdiff
path: root/root/nix/apps.nix
blob: e5d619e50f0e20b9614b75647a8a49cb645b710a (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
  perSystem =
    {
      config,
      lib,
      pkgs,
      ...
    }:
    {
      apps.checks = {
        type = "app";
        program = toString (
          pkgs.writeShellScript "lint" ''
            set -e

            "${pkgs.nix-fast-build}/bin/nix-fast-build" --skip-cached --no-link "$@"
          ''
        );
        meta.description = "run all the nix checks in parallel";
      };

      apps.lint =
        let
          devshells = builtins.filter (n: n != "common") (builtins.attrNames config.devShells);
          mkTreefmtCommand = name: "nix develop .#${name} --command treefmt";
          quotedCommands = lib.strings.concatMapStringsSep " " (
            n: lib.escapeShellArg (mkTreefmtCommand n)
          ) devshells;
        in
        {
          type = "app";
          program = toString (
            pkgs.writeShellScript "treefmt" ''
              set -xeuo pipefail

              ${pkgs.parallel}/bin/parallel -j5 -k ::: ${quotedCommands}
            ''
          );
          meta.description = "run treefmt from all the projects in parallel";
        };

    };
}