forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathzephyr.nix
52 lines (40 loc) · 1.19 KB
/
zephyr.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
{ stdenvNoCC, lib, fetchgit, runCommand }:
let
manifestJSON = builtins.fromJSON (builtins.readFile ./manifest.json);
mkModule = { name, revision, url, sha256, ... }:
stdenvNoCC.mkDerivation (finalAttrs: {
name = "zmk-module-${name}";
src = fetchgit {
inherit name url sha256;
rev = revision;
};
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir $out
ln -s ${finalAttrs.src} $out/${name}
'';
passthru = {
modulePath = "${finalAttrs.finalPackage}/${name}";
};
});
modules = lib.listToAttrs (lib.forEach manifestJSON ({ name, ... }@args:
lib.nameValuePair name (mkModule args)));
in
# Zephyr with no modules, from the frozen manifest.
# For now the modules are passed through as passthru
stdenvNoCC.mkDerivation {
name = "zephyr";
src = modules.zephyr.src;
dontBuild = true;
# This awkward structure is required by
# COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
installPhase = ''
mkdir -p $out/zephyr
mv * $out/zephyr
# uf2 is gone, not sure what replaced it
'';
passthru = {
modules = removeAttrs modules ["zephyr"];
};
}