summaryrefslogtreecommitdiff
path: root/release.nix
blob: 7b0524b5e4a8f73c24f5d660e29e70c85f574118 (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
44
45
46
47
48
# nix-build release.nix -A <system>
# i.e., nix-build release.nix -A x86_64-linux
{
  lib ? import <nixpkgs/lib>,
}:

let
  src = lib.fileset.toSource {
    root = ./.;
    fileset = lib.fileset.gitTracked ./.;
  };

  systems = [
    "x86_64-linux"
    "aarch64-linux"
    "x86_64-darwin"
    "aarch64-darwin"
  ];
in

lib.genAttrs systems (
  system:

  let
    pkgs = import <nixpkgs> {
      inherit system;
      config = { };
      overlays = [ ];
    };

    mkCheck =
      name: deps: script:
      pkgs.runCommand name { nativeBuildInputs = deps; } ''
        ${script}
        touch $out
      '';

    packages = lib.mapAttrs (lib.const lib.recurseIntoAttrs) (import ./default.nix { inherit pkgs; });

    checks = {
      deadnix = mkCheck "check-deadnix" [ pkgs.deadnix ] "deadnix --fail ${src}";
      nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] "nixfmt --check ${src}";
      statix = mkCheck "check-statix" [ pkgs.statix ] "statix check ${src}";
    };
  in

  checks // packages // { shell = import ./shell.nix { inherit pkgs; }; }
)