diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 878b46178b793..7e7cf0f0b3a75 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -24034,6 +24034,12 @@ githubId = 49368953; keys = [ { fingerprint = "D20F C904 A145 8B28 53D8 FBA0 0422 0096 01E4 87FC"; } ]; }; + WeetHet = { + name = "WeetHet"; + matrix = "@weethet:catgirl.cloud"; + github = "WeetHet"; + githubId = 43210583; + }; wegank = { name = "Weijia Wang"; email = "contact@weijia.wang"; diff --git a/pkgs/by-name/li/livekit-libwebrtc/0001-shared-libraries.patch b/pkgs/by-name/li/livekit-libwebrtc/0001-shared-libraries.patch new file mode 100644 index 0000000000000..1baf8dd630811 --- /dev/null +++ b/pkgs/by-name/li/livekit-libwebrtc/0001-shared-libraries.patch @@ -0,0 +1,15 @@ +diff --git a/BUILD.gn b/BUILD.gn +index d5289b8..598bbbc 100644 +--- a/BUILD.gn ++++ b/BUILD.gn +@@ -138,8 +138,8 @@ config("library_impl_config") { + # target_defaults and direct_dependent_settings. + config("common_inherited_config") { + defines = [] +- cflags = [] +- ldflags = [] ++ cflags = [ "-fvisibility=default" ] ++ ldflags = [ "-lavutil", "-lavformat", "-lavcodec" ] + + if (rtc_dlog_always_on) { + defines += [ "DLOG_ALWAYS_ON" ] diff --git a/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix b/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix new file mode 100644 index 0000000000000..5008a586ce76d --- /dev/null +++ b/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix @@ -0,0 +1,61 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + flit-core, + click, + nurl, + nix-prefetch-git, + nix, + coreutils, + nixfmt-rfc-style, + makeWrapper, +}: +# Based on https://github.com/milahu/gclient2nix +# but with libwebrtc-specific changes. +let + nativeDeps = [ + nurl + nix-prefetch-git + nix + coreutils + nixfmt-rfc-style + ]; +in +buildPythonPackage { + pname = "gclient2nix"; + version = "0.2.0-unstable-2024-12-19"; + pyproject = true; + + src = fetchFromGitHub { + owner = "WeetHet"; + repo = "gclient2nix"; + rev = "bdf5ab79818595be9dcfc655bd6784cf4bcdb863"; + hash = "sha256-KOXG8E2g30XyZGmM4ZnYPBSybBhHIjOZL8ZXRKYrkZQ="; + }; + + build-system = [ + flit-core + ]; + + dependencies = [ + click + ]; + + nativeBuildInputs = [ makeWrapper ]; + + postFixup = '' + wrapProgram $out/bin/gclient2nix \ + --set PATH ${lib.makeBinPath nativeDeps} + ''; + + meta = { + description = "Generate Nix expressions for projects based on the Google build tools"; + homepage = "https://github.com/WeetHet/gclient2nix"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + WeetHet + ]; + mainProgram = "gclient2nix"; + }; +} diff --git a/pkgs/by-name/li/livekit-libwebrtc/mkSystemLibraries.nix b/pkgs/by-name/li/livekit-libwebrtc/mkSystemLibraries.nix new file mode 100644 index 0000000000000..4293798faf903 --- /dev/null +++ b/pkgs/by-name/li/livekit-libwebrtc/mkSystemLibraries.nix @@ -0,0 +1,64 @@ +{ + brotli, + fontconfig, + freetype, + harfbuzz, + icu, + jsoncpp, + libpng, + libwebp, + libxml2, + libxslt, + minizip, + ffmpeg_6, +}: +{ + "brotli" = { + package = brotli; + path = "third_party/brotli/BUILD.gn"; + }; + "fontconfig" = { + package = fontconfig; + path = "third_party/fontconfig/BUILD.gn"; + }; + "freetype" = { + package = freetype; + path = "build/config/freetype/freetype.gni"; + }; + "harfbuzz-ng" = { + package = harfbuzz; + path = "third_party/harfbuzz-ng/harfbuzz.gni"; + }; + "jsoncpp" = { + package = jsoncpp; + path = "third_party/jsoncpp/BUILD.gn"; + }; + "icu" = { + package = icu; + path = "third_party/icu/BUILD.gn"; + }; + "libpng" = { + package = libpng; + path = "third_party/libpng/BUILD.gn"; + }; + "libwebp" = { + package = libwebp; + path = "third_party/libwebp/BUILD.gn"; + }; + "libxml" = { + package = libxml2; + path = "third_party/libxml/BUILD.gn"; + }; + "libxslt" = { + package = libxslt; + path = "third_party/libxslt/BUILD.gn"; + }; + "zlib" = { + package = minizip; + path = "third_party/zlib/BUILD.gn"; + }; + "ffmpeg" = { + package = ffmpeg_6; + path = "third_party/ffmpeg/BUILD.gn"; + }; +} diff --git a/pkgs/by-name/li/livekit-libwebrtc/package.nix b/pkgs/by-name/li/livekit-libwebrtc/package.nix new file mode 100644 index 0000000000000..20589f68b8799 --- /dev/null +++ b/pkgs/by-name/li/livekit-libwebrtc/package.nix @@ -0,0 +1,298 @@ +{ + stdenv, + clang, + callPackage, + lib, + gn, + fetchurl, + fetchpatch, + xcbuild, + python3, + ninja, + apple-sdk_14, + darwinMinVersionHook, + git, + cpio, + pkg-config, + glib, + alsa-lib, + pulseaudio, + nasm, + brotli, + fontconfig, + freetype, + harfbuzz, + icu, + jsoncpp, + libpng, + libwebp, + libxml2, + libxslt, + minizip, + ffmpeg_6, + writeShellScript, +}: +let + sources = callPackage ./sources.nix { }; + + platformMap = { + "x86_64" = "x64"; + "i686" = "x86"; + "arm" = "arm"; + "aarch64" = "arm64"; + }; + cpuName = stdenv.hostPlatform.parsed.cpu.name; + gnArch = platformMap."${cpuName}" or (throw "unsupported arch ${cpuName}"); + gnOs = + if stdenv.hostPlatform.isLinux then + "linux" + else if stdenv.hostPlatform.isDarwin then + "mac" + else + throw "unknown platform ${stdenv.hostPlatform.config}"; + boringSslSymbols = fetchurl { + url = "https://raw.githubusercontent.com/livekit/rust-sdks/refs/tags/webrtc-dac8015-6/webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt"; + hash = "sha256-dAweArv8zjsFPENEKi9mNBQkt4y+hh3rCqG6QZjRC20="; + }; + gnSystemLibraries = import ./mkSystemLibraries.nix { + inherit + brotli + fontconfig + freetype + harfbuzz + icu + jsoncpp + libpng + libwebp + libxml2 + libxslt + minizip + ffmpeg_6 + ; + }; + gclient2nix = python3.pkgs.callPackage ./gclient2nix.nix { }; +in +stdenv.mkDerivation { + pname = "livekit-libwebrtc"; + version = "m114"; + + src = "${sources}/src"; + + patches = [ + # Adds missing dependencies to generated LICENSE + (fetchpatch { + url = "https://raw.githubusercontent.com/livekit/rust-sdks/b41861c7b71762d5d85b3de07ae67ffcae7c3fa2/webrtc-sys/libwebrtc/patches/add_licenses.patch"; + hash = "sha256-9A4KyRW1K3eoQxsTbPX0vOnj66TCs2Fxjpsu5wO8mGI="; + }) + # Fixes the certificate chain, required for Let's Encrypt certs + (fetchpatch { + url = "https://raw.githubusercontent.com/livekit/rust-sdks/b41861c7b71762d5d85b3de07ae67ffcae7c3fa2/webrtc-sys/libwebrtc/patches/ssl_verify_callback_with_native_handle.patch"; + hash = "sha256-/gneuCac4VGJCWCjJZlgLKFOTV+x7Lc5KVFnNIKenwM="; + }) + # Adds dependencies and features required by livekit + (fetchpatch { + url = "https://raw.githubusercontent.com/livekit/rust-sdks/b41861c7b71762d5d85b3de07ae67ffcae7c3fa2/webrtc-sys/libwebrtc/patches/add_deps.patch"; + hash = "sha256-EMNYcTcBYh51Tt96+HP43ND11qGKClfx3xIPQmIBSo0="; + }) + # Fixes concurrency and localization issues + (fetchpatch { + url = "https://github.com/zed-industries/webrtc/commit/08f7a701a2eda6407670508fc2154257a3c90308.patch"; + hash = "sha256-oWYZLwqjRSHDt92MqsxsoBSMyZKj1ubNbOXZRbPpbEw="; + }) + # Required for dynamically linking to ffmpeg libraries and exposing symbols + ./0001-shared-libraries.patch + ]; + + postPatch = + '' + substituteInPlace tools/generate_shim_headers/generate_shim_headers.py \ + --replace-fail "OFFICIAL_BUILD" "GOOGLE_CHROME_BUILD" + + substituteInPlace BUILD.gn \ + --replace-fail "rtc_static_library" "rtc_shared_library" \ + --replace-fail "complete_static_lib = true" "" + + substituteInPlace webrtc.gni \ + --replace-fail "!build_with_chromium && is_component_build" "false" + + substituteInPlace rtc_tools/BUILD.gn \ + --replace-fail "\":frame_analyzer\"," "" + + for lib in ${toString (builtins.attrNames gnSystemLibraries)}; do + if [ -d "third_party/$lib" ]; then + find "third_party/$lib" -type f \ + \! -path "third_party/$lib/chromium/*" \ + \! -path "third_party/$lib/google/*" \ + \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \ + \! -regex '.*\.\(gn\|gni\|isolate\)' \ + \! -name 'LICENSE*' \ + \! -name 'COPYING*' \ + -delete + fi + done + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + ln -sf ${lib.getExe gn} buildtools/linux64/gn + substituteInPlace build/toolchain/linux/BUILD.gn \ + --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""' + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + ln -sf ${lib.getExe gn} buildtools/mac/gn + chmod +x build/toolchain/apple/linker_driver.py + patchShebangs build/toolchain/apple/linker_driver.py + substituteInPlace build/toolchain/apple/toolchain.gni --replace-fail "/bin/cp -Rc" "cp -a" + ''; + + nativeBuildInputs = + (builtins.concatLists ( + lib.mapAttrsToList ( + _: library: if (library.package ? dev) then [ library.package.dev ] else [ ] + ) gnSystemLibraries + )) + ++ [ + gn + (python3.withPackages (ps: [ ps.setuptools ])) + ninja + git + cpio + pkg-config + ] + ++ lib.optionals stdenv.isDarwin [ xcbuild ]; + + buildInputs = + [ nasm ] + ++ (lib.mapAttrsToList (_: library: library.package) gnSystemLibraries) + ++ (lib.optionals stdenv.hostPlatform.isLinux [ + glib + alsa-lib + pulseaudio + ]) + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + apple-sdk_14 + (darwinMinVersionHook "12.3") + ]; + + preConfigure = '' + echo "generate_location_tags = true" >> build/config/gclient_args.gni + echo "0" > build/util/LASTCHANGE.committime + + python build/linux/unbundle/replace_gn_files.py \ + --system-libraries ${toString (builtins.attrNames gnSystemLibraries)} + ''; + + gnFlags = + [ + "is_debug=false" + "rtc_include_tests=false" + ''target_os="${gnOs}"'' + ''target_cpu="${gnArch}"'' + "treat_warnings_as_errors=false" + "rtc_enable_protobuf=false" + "rtc_include_tests=false" + "rtc_build_examples=false" + "rtc_build_tools=false" + "rtc_libvpx_build_vp9=true" + "enable_libaom=true" + "use_dummy_lastchange=true" + "is_component_build=true" + "enable_stripping=true" + "rtc_use_h264=true" + "use_custom_libcxx=false" + "use_rtti=true" + ] + ++ (lib.optionals stdenv.hostPlatform.isLinux [ + "use_goma=false" + "rtc_use_pipewire=false" + "symbol_level=0" + "enable_iterator_debugging=false" + "rtc_use_x11=false" + "use_sysroot=false" + "is_clang=false" + ]) + ++ (lib.optionals stdenv.hostPlatform.isDarwin [ + ''mac_deployment_target="12.3"'' + "rtc_enable_symbol_export=true" + "rtc_enable_objc_symbol_export=true" + "rtc_include_dav1d_in_internal_decoder_factory=true" + "clang_use_chrome_plugins=false" + "use_lld=false" + ''clang_base_path="${clang}"'' + ]); + + ninjaFlags = + [ ":default" ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + "api/audio_codecs:builtin_audio_decoder_factory" + "api/task_queue:default_task_queue_factory" + "sdk:native_api" + "sdk:default_codec_factory_objc" + "pc:peerconnection" + "sdk:videocapture_objc" + "sdk:mac_framework_objc" + ]; + + postBuild = + lib.optionalString stdenv.hostPlatform.isLinux '' + objcopy --redefine-syms="${boringSslSymbols}" "libwebrtc.so" + '' + + '' + # Generate licenses + python3 "../../tools_webrtc/libs/generate_licenses.py" \ + --target ${if stdenv.hostPlatform.isDarwin then ":webrtc" else ":default"} $PWD $PWD + ''; + + installPhase = + '' + runHook preInstall + + mkdir -p $out/{lib,include} + cp obj/webrtc.ninja $out/ + cp args.gn $out/ + cp LICENSE.md $out/ + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + cp libwebrtc.so $out/lib/ + cp libthird_party_boringssl.so $out/lib/ + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Library/Frameworks + cp -r WebRTC.framework $out/Library/Frameworks + cp libwebrtc.dylib $out/lib + cp libthird_party_boringssl.dylib $out/lib/ + '' + + '' + cd ../.. + find . -name "*.h" -print | cpio -pd $out/include + + runHook postInstall + ''; + + postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' + boringssl="$out/lib/libthird_party_boringssl.dylib" + webrtc="$out/lib/libwebrtc.dylib" + framework="$out/Library/Frameworks/WebRTC.framework/Versions/A/WebRTC" + + install_name_tool -id "$boringssl" "$boringssl" + install_name_tool -id "$webrtc" "$webrtc" + install_name_tool -change @rpath/libthird_party_boringssl.dylib "$boringssl" "$webrtc" + install_name_tool -id "$framework" "$framework" + install_name_tool -change @rpath/libthird_party_boringssl.dylib "$boringssl" "$framework" + ''; + + passthru.updateScript = writeShellScript "update-livekit-libwebrtc" '' + set -eou pipefail + cd pkgs/by-name/li/livekit-libwebrtc + ${lib.getExe gclient2nix} --main-source-path src https://github.com/webrtc-sdk/webrtc.git m114_release + ''; + + meta = { + description = "WebRTC library used by livekit"; + homepage = "https://github.com/livekit/rust-sdks/"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ + WeetHet + niklaskorz + ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +} diff --git a/pkgs/by-name/li/livekit-libwebrtc/sources.nix b/pkgs/by-name/li/livekit-libwebrtc/sources.nix new file mode 100644 index 0000000000000..d305428d1e8c1 --- /dev/null +++ b/pkgs/by-name/li/livekit-libwebrtc/sources.nix @@ -0,0 +1,228 @@ +{ + fetchFromGitHub, + fetchFromGitiles, + fetchgit, + fetchurl, + runCommand, + lib, +}: +let + sourceDerivations = { + "src" = fetchFromGitHub { + owner = "webrtc-sdk"; + repo = "webrtc"; + rev = "dac8015ce039c8658706b222746808f01968256b"; + hash = "sha256-T5syfRzX/LfvEllVurzZPKffkciTd2inUEC2py78ZPA="; + }; + "src/base" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/base"; + rev = "fe22033c21d399a340b3f4604722463d9da25c6e"; + hash = "sha256-iqtcXEtmCNioKRxfTCwiU/NG0xlQ1R/6GE1M6qC0XTU="; + }; + "src/build" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/build"; + rev = "a9d28a095c8b349f8319ee0d241a78e2c849928f"; + hash = "sha256-5NguoLWm6v68fpyHK6SYbM6vHdaOT0quks5/SPW0XOI="; + }; + "src/buildtools" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/buildtools"; + rev = "539a6f68735c631f57ae33096e9e7fc059e049cf"; + hash = "sha256-1u4BQqXcW4Z9LPx7lMjBLK8ouKkyb576FRvB2LGwf7Q="; + }; + "src/testing" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/testing"; + rev = "ee4801b4e9c2d945fff5236d8518511e6c00a29e"; + hash = "sha256-xUfPwWVPoLxlCWHFKLWtRC1kVJgLgcvSoXPYmrseCXE="; + }; + "src/third_party" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/third_party"; + rev = "4f8bf4c6885ab577c7577c4cdd11d04eaf78e9ca"; + hash = "sha256-4ehEerUw9IvghdPPrrh+WCm/XEpVe5PjjIRbQZpIsbY="; + }; + "src/buildtools/clang_format/script" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/llvm/llvm-project/clang/tools/clang-format"; + rev = "f97059df7f8b205064625cdb5f97b56668a125ef"; + hash = "sha256-IL6ReGM6+urkXfGYe1BBOv+0XgCZv5i3Lib1q9COhig="; + }; + "src/buildtools/third_party/libc++/trunk" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx"; + rev = "bff81b702ff4b7f74b1c0ed02a4bcf6c2744a90b"; + hash = "sha256-i/FGU9F7HlGJJuwoFMV4V05pf4pvsqNxrPBN223YjZQ="; + }; + "src/buildtools/third_party/libc++abi/trunk" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi"; + rev = "307bd163607c315d46103ebe1d68aab44bf93986"; + hash = "sha256-Zka8AHFtHA4AC/Pbzc3pVqz/k2GYZYc8CeP1IXxGBUM="; + }; + "src/buildtools/third_party/libunwind/trunk" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind"; + rev = "2795322d57001de8125cfdf18cef804acff69e35"; + hash = "sha256-u6FMD83JBBusQuWU7Hx5HREvLIFWUA4iN4If8poaHbE="; + }; + "src/third_party/boringssl/src" = fetchFromGitiles { + url = "https://boringssl.googlesource.com/boringssl"; + rev = "6776d5cd8fcdf6c5e05bae2d655076dbeaa56103"; + hash = "sha256-KvQhpkn1pGQ/xPbkHcGgTTvL3GGRL1TfdSPYgfNn5bU="; + }; + "src/third_party/breakpad/breakpad" = fetchFromGitiles { + url = "https://chromium.googlesource.com/breakpad/breakpad"; + rev = "9bf8d1ec526cec139b2d3fba148ce81ccf2cceab"; + hash = "sha256-c3/ksp01+cmSyzaD5SF0Lnnw+t78RwZAKCJnwg1NGXU="; + }; + "src/third_party/catapult" = fetchFromGitiles { + url = "https://chromium.googlesource.com/catapult"; + rev = "cae7ec667dee9f5c012b54ee9ffee94eb7beda14"; + hash = "sha256-vK7rlGshfzPzaEdAxlP5vQ4USR/fC3BzPCh/rn0aAf4="; + }; + "src/third_party/ced/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/google/compact_enc_det"; + rev = "ba412eaaacd3186085babcd901679a48863c7dd5"; + hash = "sha256-ySG74Rj2i2c/PltEgHVEDq+N8yd9gZmxNktc56zIUiY="; + }; + "src/third_party/colorama/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/colorama"; + rev = "3de9f013df4b470069d03d250224062e8cf15c49"; + hash = "sha256-6ZTdPYSHdQOLYMSnE+Tp7PgsVTs3U2awGu9Qb4Rg/tk="; + }; + "src/third_party/crc32c/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/google/crc32c"; + rev = "fa5ade41ee480003d9c5af6f43567ba22e4e17e6"; + hash = "sha256-urg0bmnfMfHagLPELp4WrNCz1gBZ6DFOWpDue1KsMtc="; + }; + "src/third_party/depot_tools" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/tools/depot_tools"; + rev = "6e714e6dfe62110c95fafed4bdeb365a69c6a77e"; + hash = "sha256-7jPow77ejToE55KvQ7/eO0alMdMHcypfSyPceFAbZkw="; + }; + "src/third_party/ffmpeg" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/third_party/ffmpeg"; + rev = "8d21d41d8bec5c0b266ee305d1a708dc5c23b594"; + hash = "sha256-UjrZJBtOQiiqxtLb8x24axord3OFvyCcRcgDwiYE/jw="; + }; + "src/third_party/flatbuffers/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/google/flatbuffers"; + rev = "a56f9ec50e908362e20254fcef28e62a2f148d91"; + hash = "sha256-OQ8E+i30WRz/lPJmVDiF7+TPo4gZVu2Of9loxz3tswI="; + }; + "src/third_party/grpc/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/grpc/grpc"; + rev = "822dab21d9995c5cf942476b35ca12a1aa9d2737"; + hash = "sha256-64JEVCx/PCM0dvv7kAQvSjLc0QbRAZVBDzwD/FAV6T8="; + }; + "src/third_party/fontconfig/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/fontconfig"; + rev = "06929a556fdc39c8fe12965b69070c8df520a33e"; + hash = "sha256-0R+FEhtGXFiQWHEPRrJqaBW1JVfCojYI4NPDvYMBhoU="; + }; + "src/third_party/freetype/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/third_party/freetype2"; + rev = "9806414c15230d253d5219ea0dafeddb717307b1"; + hash = "sha256-UbWtRb24U7Cv+PecVtoNG33Q1ItmkvssmW8Bh8qlFvA="; + }; + "src/third_party/harfbuzz-ng/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz"; + rev = "2822b589bc837fae6f66233e2cf2eef0f6ce8470"; + hash = "sha256-qwtRORl/Pu4M9EvW8MdK8onFMCw/4+57FEBjoNt4qoY="; + }; + "src/third_party/google_benchmark/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/google/benchmark"; + rev = "b177433f3ee2513b1075140c723d73ab8901790f"; + hash = "sha256-h2ryAQAuHI54Cni88L85e7Np4KATGVTRdDcmUvCNeWc="; + }; + "src/third_party/gtest-parallel" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/google/gtest-parallel"; + rev = "f4d65b555894b301699c7c3c52906f72ea052e83"; + hash = "sha256-dzWXJHPb8RHqxoi/gA9npwnjAsT8gg7A90g/dx8LVwQ="; + }; + "src/third_party/googletest/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/google/googletest"; + rev = "af29db7ec28d6df1c7f0f745186884091e602e07"; + hash = "sha256-VYRjcM3dDY2FarviXyFMgSkXCqKfWXwtGAj2Msgm7zg="; + }; + "src/third_party/icu" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/deps/icu"; + rev = "d8daa943f64cd5dd2a55e9baf2e655ab4bfa5ae9"; + hash = "sha256-47Xxb5IFbRmdO3oADjn13fm7aIYFXh2R4YVZIJAy22U="; + }; + "src/third_party/jsoncpp/source" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp"; + rev = "42e892d96e47b1f6e29844cc705e148ec4856448"; + hash = "sha256-bSLNcoYBz3QCt5VuTR056V9mU2PmBuYBa0W6hFg2m8Q="; + }; + "src/third_party/libFuzzer/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer"; + rev = "debe7d2d1982e540fbd6bd78604bf001753f9e74"; + hash = "sha256-HG3KHhKQnr4hdnUK/2QhcxRdNxh38fhU54JKKzqZaio="; + }; + "src/third_party/libjpeg_turbo" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo"; + rev = "aa4075f116e4312537d0d3e9dbd5e31096539f94"; + hash = "sha256-QnXMR9qqRiYfV1sUJvKVvLQ9A022lYKbsrI9HOU9LCs="; + }; + "src/third_party/libsrtp" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/deps/libsrtp"; + rev = "5b7c744eb8310250ccc534f3f86a2015b3887a0a"; + hash = "sha256-pfLFh2JGk/g0ZZxBKTaYW9/PBpkCm0rtJeyNePUMTTc="; + }; + "src/third_party/dav1d/libdav1d" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/videolan/dav1d"; + rev = "d426d1c91075b9c552b12dd052af1cd0368f05a2"; + hash = "sha256-FivzwqCvlY89q2znGvfNks+hje/iUFHcKPb19FyAZhM="; + }; + "src/third_party/libaom/source/libaom" = fetchFromGitiles { + url = "https://aomedia.googlesource.com/aom"; + rev = "5a0903824082f41123e8365b5b99ddb6ced8971c"; + hash = "sha256-j8b0xM7hHNqYIeUQjf+c7LyzcfZVJx64Xqo9gIRtsYU="; + }; + "src/third_party/perfetto" = fetchFromGitiles { + url = "https://android.googlesource.com/platform/external/perfetto"; + rev = "20b114cd063623e63ef1b0a31167d60081567e51"; + hash = "sha256-6BpUd+BplRR/0eUIYz5SehzrpNHPfUm2Qv6U1+Mxy8g="; + }; + "src/third_party/libvpx/source/libvpx" = fetchFromGitiles { + url = "https://chromium.googlesource.com/webm/libvpx"; + rev = "7aaffe2df4c9426ab204a272ca5ca52286ca86d4"; + hash = "sha256-Uis24FzUtM38ktPG/wDJLiHZYmpmYFGbuQ/SWnmZJSA="; + }; + "src/third_party/libyuv" = fetchFromGitiles { + url = "https://chromium.googlesource.com/libyuv/libyuv"; + rev = "77c2121f7e6b8e694d6e908bbbe9be24214097da"; + hash = "sha256-LLmTW05GxoXgNkLRHp3e6gb7glMgJo1moc6lPLVHk6w="; + }; + "src/third_party/lss" = fetchFromGitiles { + url = "https://chromium.googlesource.com/linux-syscall-support"; + rev = "ce877209e11aa69dcfffbd53ef90ea1d07136521"; + hash = "sha256-hE8uZf9Fst66qJkoVYChiB8G41ie+k9M4X0W+5JUSdw="; + }; + "src/third_party/nasm" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/deps/nasm"; + rev = "7fc833e889d1afda72c06220e5bed8fb43b2e5ce"; + hash = "sha256-L+b3X3vsfpY6FSlIK/AHhxhmq2cXd50vND6uT6yn8Qs="; + }; + "src/third_party/openh264/src" = fetchFromGitiles { + url = "https://chromium.googlesource.com/external/github.com/cisco/openh264"; + rev = "09a4f3ec842a8932341b195c5b01e141c8a16eb7"; + hash = "sha256-J7Eqe2QevZh1xfap19W8AVCcwfRu7ztknnbKFJUAH1c="; + }; + "src/tools" = fetchFromGitiles { + url = "https://chromium.googlesource.com/chromium/src/tools"; + rev = "bafae7909cbbcd277d29c0da0809001a8d6f4a14"; + hash = "sha256-MK5M9RrX+cX4S7vsMgNVQ2YkNbEuvizKueuc1mA5jyU="; + }; + }; + namedSourceDerivations = builtins.mapAttrs ( + path: drv: + drv.overrideAttrs { + name = lib.strings.sanitizeDerivationName path; + } + ) sourceDerivations; +in +runCommand "combined-sources" { } ( + lib.concatLines ( + [ "mkdir $out" ] + ++ (lib.mapAttrsToList (path: drv: '' + mkdir -p $out/${path} + cp --no-preserve=mode --reflink=auto -rfT ${drv} $out/${path} + '') namedSourceDerivations) + ) +) diff --git a/pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch b/pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch deleted file mode 100644 index 2c82a2d49b688..0000000000000 --- a/pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff --git a/crates/live_kit_client/Cargo.toml b/crates/live_kit_client/Cargo.toml -index e23c63453e..d0142b83d8 100644 ---- a/crates/live_kit_client/Cargo.toml -+++ b/crates/live_kit_client/Cargo.toml -@@ -40,10 +40,10 @@ nanoid = { workspace = true, optional = true} - parking_lot.workspace = true - postage.workspace = true - --[target.'cfg(target_os = "macos")'.dependencies] -+[target.'cfg(target_os = "none")'.dependencies] - core-foundation.workspace = true - --[target.'cfg(all(not(target_os = "macos")))'.dependencies] -+[target.'cfg(all(not(target_os = "none")))'.dependencies] - async-trait = { workspace = true } - collections = { workspace = true } - gpui = { workspace = true } -diff --git a/crates/live_kit_client/build.rs b/crates/live_kit_client/build.rs -index 2fdfd982bf..7272614b87 100644 ---- a/crates/live_kit_client/build.rs -+++ b/crates/live_kit_client/build.rs -@@ -36,7 +36,7 @@ const MACOS_TARGET_VERSION: &str = "10.15.7"; - - fn main() { - if cfg!(all( -- target_os = "macos", -+ target_os = "none", - not(any(test, feature = "test-support", feature = "no-webrtc")), - )) { - let swift_target = get_swift_target(); -diff --git a/crates/live_kit_client/src/live_kit_client.rs b/crates/live_kit_client/src/live_kit_client.rs -index 4820a4eedb..6179e6c55a 100644 ---- a/crates/live_kit_client/src/live_kit_client.rs -+++ b/crates/live_kit_client/src/live_kit_client.rs -@@ -2,16 +2,16 @@ - - use std::sync::Arc; - --#[cfg(all(target_os = "macos", not(any(test, feature = "test-support"))))] -+#[cfg(all(target_os = "none", not(any(test, feature = "test-support"))))] - pub mod prod; - --#[cfg(all(target_os = "macos", not(any(test, feature = "test-support"))))] -+#[cfg(all(target_os = "none", not(any(test, feature = "test-support"))))] - pub use prod::*; - --#[cfg(any(test, feature = "test-support", not(target_os = "macos")))] -+#[cfg(any(test, feature = "test-support", not(target_os = "none")))] - pub mod test; - --#[cfg(any(test, feature = "test-support", not(target_os = "macos")))] -+#[cfg(any(test, feature = "test-support", not(target_os = "none")))] - pub use test::*; - - pub type Sid = String; diff --git a/pkgs/by-name/ze/zed-editor/package.nix b/pkgs/by-name/ze/zed-editor/package.nix index 2a87dae3f59a3..7f04320f1f273 100644 --- a/pkgs/by-name/ze/zed-editor/package.nix +++ b/pkgs/by-name/ze/zed-editor/package.nix @@ -35,6 +35,10 @@ darwinMinVersionHook, makeWrapper, nodejs_22, + libGL, + libX11, + libXext, + livekit-libwebrtc, withGLES ? false, }: @@ -89,35 +93,42 @@ let in rustPlatform.buildRustPackage rec { pname = "zed-editor"; - version = "0.165.4"; + version = "0.166.1"; src = fetchFromGitHub { owner = "zed-industries"; repo = "zed"; - rev = "refs/tags/v${version}"; - hash = "sha256-g+ZHchlxeNDkxUM306OK3BsjrvO3snF4vcQQZJSIhLc="; + tag = "v${version}"; + hash = "sha256-ss4dz9qPAP6eIYbG3S5QJaSR5zEyEqLBjfacj/eb7AE="; }; - patches = - [ - # Zed uses cargo-install to install cargo-about during the script execution. - # We provide cargo-about ourselves and can skip this step. - # Until https://github.com/zed-industries/zed/issues/19971 is fixed, - # we also skip any crate for which the license cannot be determined. - ./0001-generate-licenses.patch - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # The Swift variant of livekit currently used inside Zed requires - # Swift 6, which is not available in nixpkgs yet: - # https://github.com/NixOS/nixpkgs/issues/343210 - # The Rust variant of livekit for Zed is still pending and there is no - # schedule when it will be finished: - # https://github.com/zed-industries/zed/pull/13343 - ./0002-disable-livekit-darwin.patch - ]; + patches = [ + # Zed uses cargo-install to install cargo-about during the script execution. + # We provide cargo-about ourselves and can skip this step. + # Until https://github.com/zed-industries/zed/issues/19971 is fixed, + # we also skip any crate for which the license cannot be determined. + ./0001-generate-licenses.patch + # See https://github.com/zed-industries/zed/pull/21661#issuecomment-2524161840 + "script/patches/use-cross-platform-livekit.patch" + ]; + + postPatch = + lib.optionalString stdenv.hostPlatform.isLinux '' + # Dynamically link WebRTC instead of static + substituteInPlace ../${pname}-${version}-vendor/webrtc-sys-*/build.rs \ + --replace-fail "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc" + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + # On Darwin, linking against the dylib results in Rust linker errors, while + # linking against the framework works fine. + substituteInPlace ../${pname}-${version}-vendor/webrtc-sys-*/build.rs \ + --replace-fail "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=framework=webrtc" \ + --replace-fail 'println!("cargo:rustc-link-search=native={}", webrtc_lib.to_str().unwrap());' \ + 'println!("cargo:rustc-link-search=framework={}/Library/Frameworks", webrtc_dir.to_str().unwrap());' + ''; useFetchCargoVendor = true; - cargoHash = "sha256-ZNXvuHX9b3T58FUs9TjpfiGYNr9J3IDbz2JE6Vy7Sg0="; + cargoHash = "sha256-HbOdY+6FKGTK5gW2BkWSdciBvTx+oKhCchFvwKEoGNE="; nativeBuildInputs = [ @@ -151,14 +162,16 @@ rustPlatform.buildRustPackage rec { libxkbcommon wayland xorg.libxcb + # required by livekit: + libGL + libX11 + libXext ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_15 - # This will need to be increased to 12.3 once - # https://github.com/zed-industries/zed/pull/13343 - # is merged and released, as ScreenCaptureKit is only available on 12.3 and up: + # ScreenCaptureKit, required by livekit, is only available on 12.3 and up: # https://developer.apple.com/documentation/screencapturekit - (darwinMinVersionHook "10.15") + (darwinMinVersionHook "12.3") ]; cargoBuildFlags = [ @@ -183,6 +196,7 @@ rustPlatform.buildRustPackage rec { ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled."; # Used by `zed --version` RELEASE_VERSION = version; + LK_CUSTOM_WEBRTC = livekit-libwebrtc; }; RUSTFLAGS = if withGLES then "--cfg gles" else ""; @@ -286,7 +300,7 @@ rustPlatform.buildRustPackage rec { passthru = { updateScript = gitUpdater { rev-prefix = "v"; - ignoredVersions = "pre"; + ignoredVersions = "(*-pre|0.999999.0|0.9999-temporary)"; }; fhs = fhs { }; fhsWithPackages = f: fhs { additionalPkgs = f; }; @@ -295,7 +309,7 @@ rustPlatform.buildRustPackage rec { meta = { description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter"; homepage = "https://zed.dev"; - changelog = "https://github.com/zed-industries/zed/releases/tag/v${version}"; + changelog = "https://github.com/zed-industries/zed/releases/tag/${src.tag}"; license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ GaetanLepage