summaryrefslogtreecommitdiff
path: root/test/lib/flake.nix
blob: 985c4218565b1b0366194c6ec9a2ac58dda506d1 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    call-flake.url = "github:divnix/call-flake";
  };

  outputs = {
    self,
    nixpkgs,
    call-flake,
    ...
  }: let
    inherit (nixpkgs) lib;

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

    forSystem = system: fn: fn nixpkgs.legacyPackages.${system};
    forAllSystems = fn: lib.genAttrs systems (sys: forSystem sys fn);
  in {
    devShells = forAllSystems (pkgs: {
      default = pkgs.mkShell {
        packages = [pkgs.hello];
      };
    });

    flatPackages = forSystem "x86_64-linux" ({hello, ...}: {inherit hello;});

    packages = forAllSystems (pkgs: {
      inherit (pkgs) hello;
      default = pkgs.hello;
    });

    workflowMatrix = let
      platforms = {
        x86_64-linux = {
          os = "ubuntu-latest";
          arch = "x64";
        };

        aarch64-linux = {
          os = "ubuntu-latest";
          arch = "aarch64";
        };
      };

      inherit ((call-flake ../../.).lib {inherit platforms;}) mkMatrix mkMatrix';

      jobs = lib.flatten (
        (mkMatrix' {
          root = self;
          output = "flatPackages";
        })
        ++ (mkMatrix {
          root = self;
          output = "packages";
        })
      );
    in {
      include = jobs;
    };
  };
}