Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, fetchFromGitHub
4, pkg-config
5, python3
6, libffi
7, readline
8}:
9
10stdenv.mkDerivation rec {
11 pname = "micropython";
12 version = "1.19.1";
13
14 src = fetchFromGitHub {
15 owner = "micropython";
16 repo = "micropython";
17 rev = "v${version}";
18 sha256 = "sha256-BoX3Z3Zr/AQqkgRrq+UVgdoDqNESDTNsY9AtrElpzfA=";
19 fetchSubmodules = true;
20 };
21
22 nativeBuildInputs = [ pkg-config python3 ];
23
24 buildInputs = [ libffi readline ];
25
26 buildPhase = ''
27 runHook preBuild
28 make -C mpy-cross
29 make -C ports/unix
30 runHook postBuild
31 '';
32
33 doCheck = true;
34
35 skippedTests = ""
36 + lib.optionalString (stdenv.isDarwin) " -e uasyncio_basic -e uasyncio_heaplock -e uasyncio_wait_task"
37 + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) " -e ffi_callback"
38 + lib.optionalString (stdenv.isLinux && stdenv.isAarch64) " -e float_parse"
39 ;
40
41 checkPhase = ''
42 runHook preCheck
43 pushd tests
44 ${python3.interpreter} ./run-tests.py ${skippedTests}
45 popd
46 runHook postCheck
47 '';
48
49 installPhase = ''
50 runHook preInstall
51 mkdir -p $out/bin
52 install -Dm755 ports/unix/micropython -t $out/bin
53 runHook postInstall
54 '';
55
56 meta = with lib; {
57 description = "A lean and efficient Python implementation for microcontrollers and constrained systems";
58 homepage = "https://micropython.org";
59 platforms = platforms.unix;
60 license = licenses.mit;
61 maintainers = with maintainers; [ prusnak sgo ];
62 };
63}