-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathflake.nix
91 lines (79 loc) · 2.48 KB
/
flake.nix
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{
description = "Build Zephyr projects on Nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pyproject-nix.url = "github:nix-community/pyproject.nix";
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
zephyr.url = "github:zephyrproject-rtos/zephyr/v3.7.0";
zephyr.flake = false;
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
zephyr,
pyproject-nix,
nix-github-actions,
}:
(
let
inherit (nixpkgs) lib;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
# Flakes output schema shenanigans
clean = lib.flip removeAttrs [
"override"
"overrideDerivation"
"callPackage"
"overrideScope"
"overrideScope'"
"newScope"
"packages"
"sdks"
];
in
{
checks = self.packages;
githubActions = nix-github-actions.lib.mkGithubMatrix {
# Filter out unversioned (latest SDK) attributes for less CI jobs.
# These are also tested as explicitly versioned attributes.
checks = lib.mapAttrs (
_:
lib.filterAttrs (
attr: _:
!lib.elem attr [
"hosttools"
"sdk"
"sdkFull"
]
)
) (nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.checks);
};
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
packages' = pkgs.callPackage ./. {
zephyr-src = zephyr;
inherit pyproject-nix;
};
sdks' = removeAttrs packages'.sdks [ "latest" ];
inherit (lib) nameValuePair;
in
# Again, Flakes output schema is stupid and only allows for a flat attrset, no nested sets.
# While incredibly unfriendly, fold the nested SDK sets into the packages set to make flakes less pissy.
clean packages'
// (lib.listToAttrs (
lib.concatLists (
lib.mapAttrsToList (version: v: [
(nameValuePair "sdk-${version}" v.sdk)
(nameValuePair "sdkFull-${version}" v.sdkFull)
(nameValuePair "hosttools-${version}" v.hosttools)
]) sdks'
)
))
);
}
);
}