Newer
Older
packageOverrides = self: super: {
pyparsing = super.pyparsing.overridePythonAttrs( old: rec {
version = "2.3.1";
src = super.fetchPypi {
pname="pyparsing";
inherit version;
sha256="66c9268862641abcac4a96ba74506e594c884e3f57690a696d21ad8210ed667a";
};
});
};
in pkgs.python3.override{inherit packageOverrides;};
python3RequiredPackages = p: with p; [
p.setuptools
p.click
p.pyserial
p.future
p.cryptography
p.pyparsing
p.pyelftools
];
cmake (python3'.withPackages python3RequiredPackages) git ncurses flex bison gperf ninja
(pkgs.callPackage ./esp32-toolchain.nix {})
];
shellSetup = ''
export NIX_CFLAGS_LINK=-lncurses
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
export IDF_TOOLS_PATH=$IDF_PATH/tools
'';
in rec {
shell = pkgs.stdenv.mkDerivation {
name = "esp-idf-env";
buildInputs = qthingDependencies;
shellHook = shellSetup;
};
mkProject = { name, device, environment }: let
src = pkgs.runCommand "${name}-src" {} ''
cp --reflink=auto -r ${./.} $out
chmod -R u+w $out
cp --reflink=auto -r ${device} $out/main/device
cp --reflink=auto ${environment} $out/main/environment.h
'';
flashScript = pkgs.writeScript "flash" ''
PATH=${pkgs.esptool}/bin/:$PATH
cd @out@
esptool.py "$@" write_flash @flash_cmdline@
'';
in pkgs.stdenv.mkDerivation {
inherit name src;
buildInputs = qthingDependencies;
configurePhase = shellSetup + ''
patchShebangs esp-idf
'';
buildPhase = ''
make -j $NIX_BUILD_CORES
flash_cmdline=$(make print_flash_cmd) substituteAll ${flashScript} build/flash
chmod +x build/flash
'';
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/bootloader
cp build/bootloader/bootloader.bin $out/bootloader
cp build/{default,qthing}.bin $out
cp build/flash $out/bin
for path in "$(egrep --only-matching '/build/[^ ]+' $out/bin/flash)"; do
cp $path $out/bootloader
substituteInPlace $out/bin/flash --replace "$path" "bootloader/$(basename $path)"
done
'';
};
}