summary refs log tree commit diff
path: root/nix/checks.nix
blob: bbaf78a9c8b9481ed3b8aeab164a2b58bece3229 (plain) (blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022 Unikie

{ config ? import ../nix/eval-config.nix {} }:

{
  recurseForDerivations = true;

  doc-links = config.pkgs.callPackage (
    { lib, runCommand, ruby, wget }:
    runCommand "spectrum-doc-links" {
      doc = import ../Documentation { inherit config; };
      nativeBuildInputs = [ ruby wget ];
    } ''
      mkdir root
      ln -s $doc root/doc
      ruby -run -e httpd -- --port 4000 root &
      wget -r -nv --delete-after --no-parent --retry-connrefused http://localhost:4000/doc/
      touch $out
    ''
  ) {};

  rustfmt = config.pkgs.callPackage (
    { lib, runCommand, rustfmt }:
    runCommand "spectrum-rustfmt" {
      src = lib.cleanSourceWith {
        filter = path: type:
          (builtins.baseNameOf path != "build" && type == "directory")
          || builtins.match ''.*[^/]\.rs'' path != null;
        src = lib.cleanSource ../.;
      };

      nativeBuildInputs = [ rustfmt ];
    } ''
      shopt -s globstar
      rustfmt --check $src/**/*.rs
      touch $out
    ''
  ) {};

  shellcheck = config.pkgs.callPackage (
    { lib, runCommand, shellcheck }:
    runCommand "spectrum-shellcheck" {
      src = lib.cleanSourceWith {
        filter = path: type:
          (builtins.baseNameOf path != "build" && type == "directory")
          || builtins.match ''.*[^/]\.sh'' path != null;
        src = lib.cleanSource ../.;
      };

      nativeBuildInputs = [ shellcheck ];
    } ''
      shopt -s globstar
      shellcheck $src/**/*.sh
      touch $out
    ''
  ) {};
}