Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv 2, lib 3, fetchFromGitHub 4, autoconf 5, automake 6, libtool 7, pkg-config 8, ApplicationServices 9, CoreServices 10, pkgsStatic 11 12# for passthru.tests 13, bind 14, cmake 15, knot-resolver 16, lispPackages 17, luajitPackages 18, mosquitto 19, neovim 20, nodejs 21, ocamlPackages 22, python3 23}: 24 25stdenv.mkDerivation rec { 26 version = "1.45.0"; 27 pname = "libuv"; 28 29 src = fetchFromGitHub { 30 owner = pname; 31 repo = pname; 32 rev = "v${version}"; 33 sha256 = "sha256-qKw9QFR24Uw7pVA9isPH8Va+9/5DYuqXz6l6jWcXn+4="; 34 }; 35 36 outputs = [ "out" "dev" ]; 37 38 postPatch = let 39 toDisable = [ 40 "getnameinfo_basic" "udp_send_hang_loop" # probably network-dependent 41 "tcp_connect_timeout" # tries to reach out to 8.8.8.8 42 "spawn_setuid_fails" "spawn_setgid_fails" "fs_chown" # user namespaces 43 "getaddrinfo_fail" "getaddrinfo_fail_sync" 44 "threadpool_multiple_event_loops" # times out on slow machines 45 "get_passwd" # passed on NixOS but failed on other Linuxes 46 "tcp_writealot" "udp_multicast_join" "udp_multicast_join6" "metrics_pool_events" # times out sometimes 47 "fs_fstat" # https://github.com/libuv/libuv/issues/2235#issuecomment-1012086927 48 49 # Assertion failed in test/test-tcp-bind6-error.c on line 60: r == UV_EADDRINUSE 50 # Assertion failed in test/test-tcp-bind-error.c on line 99: r == UV_EADDRINUSE 51 "tcp_bind6_error_addrinuse" "tcp_bind_error_addrinuse_listen" 52 ] ++ lib.optionals stdenv.isDarwin [ 53 # Sometimes: timeout (no output), failed uv_listen. Someone 54 # should report these failures to libuv team. There tests should 55 # be much more robust. 56 "process_title" "emfile" "poll_duplex" "poll_unidirectional" 57 "ipc_listen_before_write" "ipc_listen_after_write" "ipc_tcp_connection" 58 "tcp_alloc_cb_fail" "tcp_ping_pong" "tcp_ref3" "tcp_ref4" 59 "tcp_bind6_error_inval" "tcp_bind6_error_addrinuse" "tcp_read_stop" 60 "tcp_unexpected_read" "tcp_write_to_half_open_connection" 61 "tcp_oob" "tcp_close_accept" "tcp_create_early_accept" 62 "tcp_create_early" "tcp_close" "tcp_bind_error_inval" 63 "tcp_bind_error_addrinuse" "tcp_shutdown_after_write" 64 "tcp_open" "tcp_write_queue_order" "tcp_try_write" "tcp_writealot" 65 "multiple_listen" "delayed_accept" 66 "shutdown_close_tcp" "shutdown_eof" "shutdown_twice" "callback_stack" 67 "tty_pty" "condvar_5" "hrtime" "udp_multicast_join" 68 # Tests that fail when sandboxing is enabled. 69 "fs_event_close_in_callback" "fs_event_watch_dir" "fs_event_error_reporting" 70 "fs_event_watch_dir_recursive" "fs_event_watch_file" 71 "fs_event_watch_file_current_dir" "fs_event_watch_file_exact_path" 72 "process_priority" "udp_create_early_bad_bind" 73 ] ++ lib.optionals stdenv.isAarch32 [ 74 # I observe this test failing with some regularity on ARMv7: 75 # https://github.com/libuv/libuv/issues/1871 76 "shutdown_close_pipe" 77 ]; 78 tdRegexp = lib.concatStringsSep "\\|" toDisable; 79 in lib.optionalString doCheck '' 80 sed '/${tdRegexp}/d' -i test/test-list.h 81 ''; 82 83 nativeBuildInputs = [ automake autoconf libtool pkg-config ]; 84 buildInputs = lib.optionals stdenv.isDarwin [ ApplicationServices CoreServices ]; 85 86 preConfigure = '' 87 LIBTOOLIZE=libtoolize ./autogen.sh 88 ''; 89 90 enableParallelBuilding = true; 91 92 # separateDebugInfo breaks static build 93 # https://github.com/NixOS/nixpkgs/issues/219466 94 separateDebugInfo = !stdenv.hostPlatform.isStatic; 95 96 doCheck = true; 97 98 # Some of the tests use localhost networking. 99 __darwinAllowLocalNetworking = true; 100 101 passthru.tests = { 102 inherit bind cmake knot-resolver mosquitto neovim nodejs; 103 inherit (lispPackages) cl-libuv; 104 luajit-libluv = luajitPackages.libluv; 105 luajit-luv = luajitPackages.luv; 106 ocaml-luv = ocamlPackages.luv; 107 python-pyuv = python3.pkgs.pyuv; 108 python-uvloop = python3.pkgs.uvloop; 109 static = pkgsStatic.libuv; 110 }; 111 112 meta = with lib; { 113 description = "A multi-platform support library with a focus on asynchronous I/O"; 114 homepage = "https://libuv.org/"; 115 changelog = "https://github.com/libuv/libuv/blob/v${version}/ChangeLog"; 116 maintainers = with maintainers; [ cstrahan ]; 117 platforms = platforms.all; 118 license = with licenses; [ mit isc bsd2 bsd3 cc-by-40 ]; 119 }; 120 121}