forked from thiskappaisgrey/nixpkgs-esp-dev-rust
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdefault.nix
More file actions
142 lines (122 loc) · 3.22 KB
/
default.nix
File metadata and controls
142 lines (122 loc) · 3.22 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{ rev ? "v5.3"
, sha256 ? "sha256-w+xyva4t21STVtfYZOXY2xw6sDc2XvJXBZSx+wd1N6Y="
, toolsToInclude ? [
"xtensa-esp-elf-gdb"
"riscv32-esp-elf-gdb"
"xtensa-esp-elf"
"esp-clang"
"riscv32-esp-elf"
"esp32ulp-elf"
"openocd-esp32"
]
, stdenv
, lib
, fetchFromGitHub
, makeWrapper
, callPackage
, python3
# Tools for using ESP-IDF.
, git
, wget
, gnumake
, flex
, bison
, gperf
, pkg-config
, cmake
, ninja
, ncurses5
, dfu-util
}:
let
src = fetchFromGitHub {
owner = "espressif";
repo = "esp-idf";
rev = rev;
sha256 = sha256;
fetchSubmodules = true;
};
allTools = callPackage (import ./tools.nix) {
toolSpecList = (builtins.fromJSON (builtins.readFile "${src}/tools/tools.json")).tools;
versionSuffix = "esp-idf-${rev}";
};
toolDerivationsToInclude = builtins.map (toolName: allTools."${toolName}") toolsToInclude;
customPython =
(python3.withPackages
(pythonPackages:
let
customPythonPackages = callPackage (import ./python-packages.nix) { inherit pythonPackages; };
in
with pythonPackages;
with customPythonPackages;
[
# This list is from `tools/requirements/requirements.core.txt` in the
# ESP-IDF checkout.
setuptools
click
pyserial
cryptography
pyparsing
pyelftools
idf-component-manager
esp-coredump
esptool
esp-idf-kconfig
esp-idf-monitor
esp-idf-size
esp-idf-panic-decoder
esp-idf-nvs-partition-gen
pyclang
freertos_gdb
# The esp idf vscode extension seems to want pip, too
pip
]));
in
stdenv.mkDerivation rec {
pname = "esp-idf";
version = rev;
inherit src;
# This is so that downstream derivations will have IDF_PATH set.
setupHook = ./setup-hook.sh;
nativeBuildInputs = [ makeWrapper ];
propagatedBuildInputs = [
# This is in propagatedBuildInputs so that downstream derivations will run
# the Python setup hook and get PYTHONPATH set up correctly.
customPython
# Tools required to use ESP-IDF.
git
wget
gnumake
flex
bison
gperf
pkg-config
cmake
ninja
ncurses5
dfu-util
] ++ toolDerivationsToInclude;
# We are including cmake and ninja so that downstream derivations (eg. shells)
# get them in their environment, but we don't actually want any of their build
# hooks to run, since we aren't building anything with them right now.
dontUseCmakeConfigure = true;
dontUseNinjaBuild = true;
dontUseNinjaInstall = true;
dontUseNinjaCheck = true;
installPhase = ''
mkdir -p $out
cp -rv . $out/
# Link the Python environment in so that:
# - The setup hook can set IDF_PYTHON_ENV_PATH to it.
# - In shell derivations, the Python setup hook will add the site-packages
# directory to PYTHONPATH.
ln -s ${customPython} $out/python-env
ln -s ${customPython}/lib $out/lib
# make esp-idf cmake git version detection happy
cd $out
git init .
git config user.email "nixbld@localhost"
git config user.name "nixbld"
git commit --date="1970-01-01 00:00:00" --allow-empty -m "make idf happy"
'';
}