-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildSmingApplication.nix
37 lines (28 loc) · 1.01 KB
/
buildSmingApplication.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
{ stdenvNoCC, python3, git, gnused, esp-sdk, sming, rsync }:
{ name ? "${attrs.pname}-${attrs.version}", src, components ? [], release ? false, ... } @ attrs:
stdenvNoCC.mkDerivation ({
inherit name src;
phases = ["unpackPhase" "prepareSming" "buildPhase" "installPhase"];
ESP_HOME = esp-sdk;
prepareSming = ''
cp -ra ${sming} $NIX_BUILD_TOP/Sming
chmod +w -R $NIX_BUILD_TOP/Sming
export SMING_HOME=$(readlink -f $NIX_BUILD_TOP/Sming/Sming)
'' + (builtins.concatStringsSep "\n" (map (c: "rsync -a ${c}/ $NIX_BUILD_TOP/Sming/") components)) + "\nchmod +w -R $NIX_BUILD_TOP/Sming\n";
buildPhase = ''
make
make flash -n | grep esptool.py > flash_cmd.sh
'';
SMING_RELEASE = if release then "1" else "";
buildInputs = [ python3 git gnused rsync];
installPhase = ''
mkdir -p $out
if [ -n "$SMING_RELEASE" ]
then
cp -r out/Esp8266/release/firmware $out/firmware
else
cp -r out/Esp8266/debug/firmware $out/firmware
fi
cp flash_cmd.sh $out/
'';
} // attrs)