nixpkgs/pkgs/development/interpreters/micropython/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.1 KiB
Nix
Raw Normal View History

{ stdenv
, lib
, fetchFromGitHub
, pkg-config
, python3
2021-09-10 11:33:43 +00:00
, libffi
, readline
}:
2019-12-04 02:52:10 +00:00
stdenv.mkDerivation rec {
pname = "micropython";
2024-10-26 12:39:15 +00:00
version = "1.24.0";
2019-12-04 02:52:10 +00:00
src = fetchFromGitHub {
2022-07-25 16:27:25 +00:00
owner = "micropython";
repo = "micropython";
rev = "v${version}";
2024-10-26 12:39:15 +00:00
hash = "sha256-cFoUa4ZpPy1MldlTeY9ISXi9ilulmhmaH5mapUDBzE8=";
2019-12-04 02:52:10 +00:00
fetchSubmodules = true;
2024-10-26 12:39:15 +00:00
# remove unused libraries from rp2 port's SDK. we leave this and the other
# ports around for users who want to override makeFlags flags to build them.
# https://github.com/micropython/micropython/blob/a61c446c0b34e82aeb54b9770250d267656f2b7f/ports/rp2/CMakeLists.txt#L17-L22
#
# shrinks uncompressed NAR by ~2.4G (though it is still large). there
# doesn't seem to be a way to avoid fetching them in the first place.
postFetch = ''
rm -rf $out/lib/pico-sdk/lib/{tinyusb,lwip,btstack}
'';
2019-12-04 02:52:10 +00:00
};
nativeBuildInputs = [ pkg-config python3 ];
2019-12-04 02:52:10 +00:00
buildInputs = [ libffi readline ];
makeFlags = [ "-C" "ports/unix" ]; # also builds mpy-cross
enableParallelBuilding = true;
2019-12-04 02:52:10 +00:00
doCheck = true;
2024-08-19 19:56:16 +00:00
__darwinAllowLocalNetworking = true; # needed for select_poll_eintr test
skippedTests = " -e select_poll_fd"
2024-08-19 19:56:16 +00:00
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) " -e ffi_callback -e float_parse -e float_parse_doubleproc"
+ lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) " -e float_parse"
;
2019-12-04 02:52:10 +00:00
checkPhase = ''
runHook preCheck
2019-12-04 02:52:10 +00:00
pushd tests
${python3.interpreter} ./run-tests.py ${skippedTests}
2019-12-04 02:52:10 +00:00
popd
runHook postCheck
2019-12-04 02:52:10 +00:00
'';
installPhase = ''
2021-06-06 14:12:00 +00:00
runHook preInstall
2019-12-04 02:52:10 +00:00
mkdir -p $out/bin
2023-09-25 14:25:49 +00:00
install -Dm755 ports/unix/build-standard/micropython -t $out/bin
install -Dm755 mpy-cross/build/mpy-cross -t $out/bin
2021-06-06 14:12:00 +00:00
runHook postInstall
2019-12-04 02:52:10 +00:00
'';
meta = with lib; {
description = "Lean and efficient Python implementation for microcontrollers and constrained systems";
homepage = "https://micropython.org";
platforms = platforms.unix;
2019-12-04 02:52:10 +00:00
license = licenses.mit;
2021-09-10 11:33:43 +00:00
maintainers = with maintainers; [ prusnak sgo ];
2019-12-04 02:52:10 +00:00
};
}