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
qthingBaseRepo = pkgs.runCommand "qthing" {} ''
for file in CMakeLists.txt components esp-idf sdkconfig; do
ln -s ${./.}/$file $out/$file
done
for file in *; do
[[ "$file" == environment.h ]] && continue
ln -s ${./.}/qthing/$file $out/qthing/$file
in rec {
shell = pkgs.stdenv.mkDerivation {
name = "esp-idf-env";
buildInputs = qthingDependencies;
shellHook = shellSetup;
};
mkProject = { name, src, environment }: let
flashScript = pkgs.writeScript "flash" ''
PATH=${pkgs.esptool}/bin/:$PATH
cd @out@
esptool.py "$@" write_flash @flash_cmdline@
'';
in pkgs.stdenv.mkDerivation {
unpackPhase = ''
cp --reflink=auto -r ${qthingBaseRepo}/* ./
chmod u+w qthing
cp --reflink=auto -r ${src} ./main
cp --reflink=auto ${environment} ./qthing/environment.h
ninja -C build -j $NIX_BUILD_CORES
flash_cmdline=$(cat build/flash_project_args | tr '\n' ' ') substituteAll ${flashScript} build/flash
chmod +x build/flash
'';
installPhase = ''
mkdir -p $out/bin
for path in $(cd build; find -iname '*.bin' -and -not -wholename '*/CMakeFiles/*'); do
mkdir -p $out/$(dirname $path)
cp build/$path $out/$path