forked from svelterust/esp32
-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
60 lines (59 loc) · 1.5 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
}: let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config = {
permittedInsecurePackages = [ "python-2.7.18.7" ];
};
};
esp32 = pkgs.dockerTools.pullImage {
imageName = "espressif/idf-rust";
imageDigest = "sha256:83a40f1feeeb9eb3e5c00055b313d8cbe2201de1ee8455f2ffc00f7e71dddf0d";
sha256 = "0kikm5v91y0s86kx7wkrb2cm52dd0pq4ll58bv0xdbmnfxl374al";
finalImageName = "espressif/idf-rust";
finalImageTag = "esp32_latest";
};
in {
packages.${system}.esp32 = pkgs.stdenv.mkDerivation {
name = "esp32";
src = esp32;
unpackPhase = ''
mkdir -p source
tar -C source -xvf $src
'';
sourceRoot = "source";
nativeBuildInputs = [
pkgs.autoPatchelfHook
pkgs.jq
];
buildInputs = [
pkgs.xz
pkgs.zlib
pkgs.libxml2
pkgs.python2
pkgs.libudev-zero
pkgs.stdenv.cc.cc
];
buildPhase = ''
jq -r '.[0].Layers | @tsv' < manifest.json > layers
'';
installPhase = ''
mkdir -p $out
for i in $(< layers); do
tar -C $out -xvf "$i" home/esp/.cargo home/esp/.rustup || true
done
mv -t $out $out/home/esp/{.cargo,.rustup}
rmdir $out/home/esp
rmdir $out/home
# [ -d $out/.cargo ] && [ -d $out/.rustup ]
'';
};
};
}