diff --git a/pkgs/by-name/go/goofcord/node-modules.nix b/pkgs/by-name/go/goofcord/node-modules.nix new file mode 100644 index 0000000000000..7f1c749e5df9a --- /dev/null +++ b/pkgs/by-name/go/goofcord/node-modules.nix @@ -0,0 +1,59 @@ +# fixed output derivation for node_modules +{ + lib, + stdenv, + goofcord, + bun, + nodejs, + writableTmpDirAsHomeHook, +}: +stdenv.mkDerivation { + inherit (goofcord) version src; + pname = goofcord.pname + "-modules"; + + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ + "GIT_PROXY_COMMAND" + "SOCKS_SERVER" + ]; + + nativeBuildInputs = [ + bun + nodejs + writableTmpDirAsHomeHook + ]; + + dontConfigure = true; + dontFixup = true; + + buildPhase = '' + runHook preBuild + + export BUN_INSTALL_CACHE_DIR=$(mktemp -d) + export npm_config_build_from_source=true + export ELECTRON_SKIP_BINARY_DOWNLOAD=1 + + bun install \ + --frozen-lockfile \ + --linker=hoisted \ + --no-progress + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + cp -R ./node_modules $out + + runHook postInstall + ''; + + outputHash = + { + x86_64-linux = "sha256-faR2KW27lqilZUo24cR3uJCSW4+oy5EJRDjl+0SKYzk="; + aarch64-linux = "sha256-8QTACb9YEtMNDjJWCuMINrWQcMI7DU8qppBXHjvYjww="; + } + .${stdenv.hostPlatform.system} or (throw "Unsupported system ${stdenv.hostPlatform.system}"); + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; +} diff --git a/pkgs/by-name/go/goofcord/package.nix b/pkgs/by-name/go/goofcord/package.nix index 1e53cb891323c..394102f5e17cc 100644 --- a/pkgs/by-name/go/goofcord/package.nix +++ b/pkgs/by-name/go/goofcord/package.nix @@ -1,68 +1,83 @@ { lib, stdenv, + callPackage, fetchFromGitHub, - pnpm_9, - fetchPnpmDeps, - pnpmConfigHook, - nodejs_22, - nix-update-script, + bun, + nodejs_24, electron, - pipewire, - libpulseaudio, + libxkbcommon, + libx11, + libxcb, + libxtst, makeShellWrapper, makeDesktopItem, copyDesktopItems, }: - let - pnpm = pnpm_9.override { nodejs = nodejs_22; }; + venbindAddon = callPackage ./venbind-addon.nix { }; + venmicAddon = callPackage ./venmic-addon.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "goofcord"; - version = "1.7.1"; + version = "2.1.1"; src = fetchFromGitHub { owner = "Milkshiift"; repo = "GoofCord"; - rev = "v${finalAttrs.version}"; - hash = "sha256-fx/RKnUhXhaWVd/KYPVxr19/Q8o1ovm2TgMTcTYjE3Q="; + tag = "v${finalAttrs.version}"; + hash = "sha256-BC+Fu/sf1MO/zHkiDvKeoRhfUniWRpLPkyeEXTkYlkY="; }; nativeBuildInputs = [ - pnpmConfigHook - pnpm - nodejs_22 + bun + nodejs_24 makeShellWrapper copyDesktopItems ]; buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ - libpulseaudio - pipewire + libxkbcommon + libx11 + libxcb + libxtst (lib.getLib stdenv.cc.cc) ]; - pnpmDeps = fetchPnpmDeps { - inherit (finalAttrs) pname version src; - inherit pnpm; - fetcherVersion = 3; - hash = "sha256-NKind57XDW7I5XNmjAu4cqkK5UVNAaKewpfOTNzF2BM="; - }; + node-modules = callPackage ./node-modules.nix { nodejs = nodejs_24; }; env = { ELECTRON_SKIP_BINARY_DOWNLOAD = 1; + GOOFCORD_VENMIC_PATH = "${venmicAddon}/venmic.node"; + GOOFCORD_VENBIND_PATH = "${venbindAddon}/venbind.node"; }; + configurePhase = '' + runHook preConfigure + + cp -R ${finalAttrs.node-modules} node_modules + chmod -R u+w node_modules + patchShebangs node_modules/.bin + patchShebangs node_modules/@typescript/native-preview/bin + + runHook postConfigure + ''; + + preBuild = lib.optionalString stdenv.hostPlatform.isLinux '' + cp -r ${electron.dist} electron-dist + chmod -R u+w electron-dist + ''; + buildPhase = '' runHook preBuild - pnpm build + bun run build -- --skipTypecheck - npm exec electron-builder -- \ + node node_modules/electron-builder/out/cli/cli.js \ --dir \ - -c.electronDist="${electron.dist}" \ - -c.electronVersion="${electron.version}" + -c.electronDist="${if stdenv.hostPlatform.isLinux then "electron-dist" else electron.dist}" \ + -c.electronVersion="${electron.version}" \ + -c.npmRebuild=false runHook postBuild ''; @@ -73,13 +88,21 @@ stdenv.mkDerivation (finalAttrs: { mkdir -p "$out/share/lib/goofcord" cp -r ./dist/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/goofcord" - install -Dm644 "build/icon.png" "$out/share/icons/hicolor/256x256/apps/goofcord.png" + install -Dm644 "assets/gf_icon.png" "$out/share/icons/hicolor/256x256/apps/goofcord.png" # use makeShellWrapper (instead of the makeBinaryWrapper provided by wrapGAppsHook3) for proper shell variable expansion # see https://github.com/NixOS/nixpkgs/issues/172583 makeShellWrapper "${lib.getExe electron}" "$out/bin/goofcord" \ --add-flags "$out/share/lib/goofcord/resources/app.asar" \ "''${gappsWrapperArgs[@]}" \ + --prefix LD_LIBRARY_PATH : "${ + lib.makeLibraryPath [ + libxkbcommon + libx11 + libxcb + libxtst + ] + }" \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=UseOzonePlatform,WaylandWindowDecorations,WebRTCPipeWireCapturer --enable-wayland-ime=true}}" \ --set-default ELECTRON_IS_DEV 0 \ --inherit-argv0 @@ -112,7 +135,8 @@ stdenv.mkDerivation (finalAttrs: { ]; passthru = { - updateScript = nix-update-script { }; + # This will likely failed due to multiple layer of deps. + # updateScript = nix-update-script { }; }; meta = { @@ -120,11 +144,11 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/Milkshiift/GoofCord"; downloadPage = "https://github.com/Milkshiift/GoofCord"; license = lib.licenses.osl3; - maintainers = with lib.maintainers; [ nyabinary ]; - platforms = [ - "x86_64-linux" - "aarch64-linux" + maintainers = with lib.maintainers; [ + nyabinary + miniharinn ]; + platforms = lib.platforms.linux; mainProgram = "goofcord"; }; }) diff --git a/pkgs/by-name/go/goofcord/rohrkabel-cmake.patch b/pkgs/by-name/go/goofcord/rohrkabel-cmake.patch new file mode 100644 index 0000000000000..503b8a7478c2f --- /dev/null +++ b/pkgs/by-name/go/goofcord/rohrkabel-cmake.patch @@ -0,0 +1,65 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b0b9d32..67b930a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -82,32 +82,26 @@ target_include_directories(${PROJECT_NAME} PRIVATE "include/rohrkabel") + # Setup Dependencies + # -------------------------------------------------------------------------------------------------------- + +-include("cmake/cpm.cmake") ++if (NOT DEFINED TL_EXPECTED_SOURCE_DIR) ++ message(FATAL_ERROR "[rohrkabel] TL_EXPECTED_SOURCE_DIR must be set to a local checkout") ++endif() + +-CPMFindPackage( +- NAME tl-expected +- VERSION 1.1.0 +- GIT_REPOSITORY "https://github.com/TartanLlama/expected" +- OPTIONS "EXPECTED_BUILD_TESTS OFF" +-) ++if (NOT DEFINED EREIGNIS_SOURCE_DIR) ++ message(FATAL_ERROR "[rohrkabel] EREIGNIS_SOURCE_DIR must be set to a local checkout") ++endif() + +-CPMFindPackage( +- NAME ereignis +- VERSION 3.1 +- GIT_REPOSITORY "https://github.com/Curve/ereignis" +-) ++if (NOT DEFINED BOOST_CALLABLE_TRAITS_SOURCE_DIR) ++ message(FATAL_ERROR "[rohrkabel] BOOST_CALLABLE_TRAITS_SOURCE_DIR must be set to a local checkout") ++endif() + +-CPMFindPackage( +- NAME boost_callable_traits +- GIT_TAG boost-1.85.0 +- GIT_REPOSITORY "https://github.com/boostorg/callable_traits" +-) ++if (NOT DEFINED CHANNEL_SOURCE_DIR) ++ message(FATAL_ERROR "[rohrkabel] CHANNEL_SOURCE_DIR must be set to a local checkout") ++endif() + +-CPMFindPackage( +- NAME channel +- VERSION 2.3 +- GIT_REPOSITORY "https://github.com/Curve/channel" +-) ++add_subdirectory("${TL_EXPECTED_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/rohrkabel-tl-expected") ++add_subdirectory("${EREIGNIS_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/rohrkabel-ereignis") ++add_subdirectory("${BOOST_CALLABLE_TRAITS_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/rohrkabel-boost-callable-traits") ++add_subdirectory("${CHANNEL_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/rohrkabel-channel") + + target_link_libraries(${PROJECT_NAME} PUBLIC tl::expected cr::ereignis Boost::callable_traits cr::channel) + +diff --git a/src/core.cpp b/src/core.cpp +index 77a57bd..917e491 100644 +--- a/src/core.cpp ++++ b/src/core.cpp +@@ -9,6 +9,7 @@ + + #include + #include ++#include + + #include + diff --git a/pkgs/by-name/go/goofcord/venbind-addon.nix b/pkgs/by-name/go/goofcord/venbind-addon.nix new file mode 100644 index 0000000000000..e496e354ad961 --- /dev/null +++ b/pkgs/by-name/go/goofcord/venbind-addon.nix @@ -0,0 +1,79 @@ +{ + lib, + stdenv, + rustPlatform, + fetchFromGitHub, + cmake, + pkg-config, + llvmPackages, + libx11, + libxtst, + libxdmcp, + libxkbfile, + libxkbcommon, + libxcb, + wayland, + xorgproto, +}: +let + venbindVersion = "0.1.7"; +in +rustPlatform.buildRustPackage { + pname = "venbind"; + version = venbindVersion; + + src = fetchFromGitHub { + owner = "tuxinal"; + repo = "venbind"; + rev = "v${venbindVersion}"; + hash = "sha256-6gPyQ6JjqvM2AUuIxCfO0nOLJfyQTX5bbsbKDzlNSqo="; + fetchSubmodules = true; + }; + + cargoHash = "sha256-FZTXj8f+ezRhElovKhF3khWc5SqC+22tDHlFe9IHuwo="; + + nativeBuildInputs = [ + pkg-config + cmake + ]; + + buildInputs = [ + llvmPackages.libclang + libx11 + libxtst + libxdmcp + libxkbfile + libxkbcommon + libxcb + wayland + xorgproto + ]; + + LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; + BINDGEN_EXTRA_CLANG_ARGS = lib.concatStringsSep " " [ + "-I${stdenv.cc.libc.dev}/include" + "-I${xorgproto}/include" + "-I${libx11.dev}/include" + "-I${libxdmcp.dev}/include" + "-I${libxcb.dev}/include" + "-I${libxkbcommon.dev}/include" + "-I${libxkbfile.dev}/include" + ]; + + doCheck = false; + + installPhase = '' + runHook preInstall + + addon=$(find target -path "*/release/*" \( -name "*.node" -o -name "libvenbind.so" \) | head -n1) + if [ -z "$addon" ]; then + echo "venbind: native output not found" >&2 + exit 1 + fi + + mkdir -p $out + cp "$addon" $out/venbind.node + + runHook postInstall + ''; +} diff --git a/pkgs/by-name/go/goofcord/venmic-addon.nix b/pkgs/by-name/go/goofcord/venmic-addon.nix new file mode 100644 index 0000000000000..9dd15c83f32ef --- /dev/null +++ b/pkgs/by-name/go/goofcord/venmic-addon.nix @@ -0,0 +1,135 @@ +{ + lib, + stdenv, + applyPatches, + fetchFromGitHub, + cmake, + ninja, + pkg-config, + nodejs_24, + pipewire, + libpulseaudio, + range-v3, + glaze, + spdlog, + fmt, + openssl, +}: +let + venmicVersion = "6.1.0"; + + venmicSrc = fetchFromGitHub { + owner = "Vencord"; + repo = "venmic"; + rev = "v${venmicVersion}"; + hash = "sha256-0UP8a2bfhWGsB2Lg/GeIBu4zw1zHnXbitT8vU+DLeEY="; + }; + + rohrkabelSrc = fetchFromGitHub { + owner = "Curve"; + repo = "rohrkabel"; + rev = "v7.0"; + hash = "sha256-XlpLYTCtV5gzmv3w/7gRtkf4JGgSrWH/Laenxmd5Pj8="; + }; + + rohrkabelSrcPatched = applyPatches { + name = "rohrkabel-src-patched"; + src = rohrkabelSrc; + patches = [ ./rohrkabel-cmake.patch ]; + }; + + channelSrc = fetchFromGitHub { + owner = "Curve"; + repo = "channel"; + rev = "v2.3"; + hash = "sha256-lU4QdShUP64Tie5o7rh7rkGlHgiMcPaLWaczkVTl+Jc="; + }; + + ereignisSrc = fetchFromGitHub { + owner = "Curve"; + repo = "ereignis"; + rev = "v3.1"; + hash = "sha256-1vP9gnC+Gzj07NabKPUSJdbbqLpvHwmXoAh+htZxnu8="; + }; + + boostCallableTraitsSrc = fetchFromGitHub { + owner = "boostorg"; + repo = "callable_traits"; + rev = "boost-1.85.0"; + hash = "sha256-XbO+SB5QhKAJigL/SBl9OIIQl49u6pUuqAMguU8SftQ="; + }; + + tlExpectedSrc = fetchFromGitHub { + owner = "TartanLlama"; + repo = "expected"; + rev = "v1.1.0"; + hash = "sha256-AuRU8VI5l7Th9fJ5jIc/6mPm0Vqbbt6rY8QCCNDOU50="; + }; + + nodeAddonApi = fetchFromGitHub { + owner = "nodejs"; + repo = "node-addon-api"; + rev = "v8.0.0"; + hash = "sha256-k3v8lK7uaEJvcaj1sucTjFZ6+i5A6w/0Uj9rYlPhjCE="; + }; + + cmakeDeps = [ + range-v3 + glaze + spdlog + fmt + ]; +in +stdenv.mkDerivation { + pname = "venmic-addon"; + version = venmicVersion; + + src = venmicSrc; + patches = [ ./venmic-cmake.patch ]; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + buildInputs = [ + nodejs_24 + pipewire + libpulseaudio + openssl + ] + ++ cmakeDeps; + + cmakeFlags = [ + "-Dvenmic_addon=ON" + "-Dvenmic_server=OFF" + "-Dvenmic_prefer_remote=OFF" + "-DTL_EXPECTED_SOURCE_DIR=${tlExpectedSrc}" + "-DROHRKABEL_SOURCE_DIR=${rohrkabelSrcPatched}" + "-DCHANNEL_SOURCE_DIR=${channelSrc}" + "-DEREIGNIS_SOURCE_DIR=${ereignisSrc}" + "-DBOOST_CALLABLE_TRAITS_SOURCE_DIR=${boostCallableTraitsSrc}" + "-DCMAKE_JS_INC=${nodejs_24}/include/node;${nodeAddonApi}" + "-DOPENSSL_ROOT_DIR=${openssl}" + ]; + + preConfigure = '' + export CMAKE_PREFIX_PATH="${lib.makeSearchPath "lib/cmake" cmakeDeps}:${lib.makeSearchPath "share/cmake" cmakeDeps}" + ''; + + installPhase = '' + runHook preInstall + + addon=$(find . -name "*.node" -maxdepth 6 | head -n1) + if [ -z "$addon" ]; then + echo "venmic: addon output not found" >&2 + exit 1 + fi + + mkdir -p $out + cp "$addon" $out/venmic.node + + runHook postInstall + ''; +} diff --git a/pkgs/by-name/go/goofcord/venmic-cmake.patch b/pkgs/by-name/go/goofcord/venmic-cmake.patch new file mode 100644 index 0000000000000..8ceb1fda2caf9 --- /dev/null +++ b/pkgs/by-name/go/goofcord/venmic-cmake.patch @@ -0,0 +1,114 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index af314c0..277fe57 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -83,43 +83,14 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC VENMIC_VERSION="${PROJECT_VERS + # Setup Dependencies + # -------------------------------------------------------------------------------------------------------- + +-include("cmake/cpm.cmake") +- +-CPMFindPackage( +- NAME rohrkabel +- VERSION 7.0 +- GIT_REPOSITORY "https://github.com/Curve/rohrkabel" +-) +- +-CPMFindPackage( +- NAME tl-expected +- VERSION 1.1.0 +- GIT_REPOSITORY "https://github.com/TartanLlama/expected" +-) +- +-CPMFindPackage( +- NAME channel +- VERSION 2.3 +- GIT_REPOSITORY "https://github.com/Curve/channel" +-) +- +-CPMFindPackage( +- NAME range-v3 +- GIT_TAG 0.12.0 +- GIT_REPOSITORY "https://github.com/ericniebler/range-v3" +-) +- +-CPMFindPackage( +- NAME glaze +- VERSION 2.6.8 +- GIT_REPOSITORY "https://github.com/stephenberry/glaze" +-) +- +-CPMFindPackage( +- NAME spdlog +- VERSION 1.14.1 +- GIT_REPOSITORY "https://github.com/gabime/spdlog" +-) ++if (NOT DEFINED ROHRKABEL_SOURCE_DIR) ++ message(FATAL_ERROR "[venmic] ROHRKABEL_SOURCE_DIR must be set to a local checkout") ++endif() ++ ++add_subdirectory("${ROHRKABEL_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/rohrkabel") ++find_package(range-v3 CONFIG REQUIRED) ++find_package(glaze CONFIG REQUIRED) ++find_package(spdlog CONFIG REQUIRED) + + target_link_libraries(${PROJECT_NAME} PUBLIC cr::rohrkabel tl::expected cr::channel glaze::glaze range-v3::meta spdlog::spdlog) + +@@ -148,8 +119,10 @@ endif() + # Setup Node Addon + # -------------------------------------------------------------------------------------------------------- + +-if (venmic_addon AND NOT CMAKE_JS_VERSION) +- message(FATAL_ERROR "[venmic] Please build the addon using CMake.js") ++if (venmic_addon) ++ if (NOT CMAKE_JS_INC) ++ message(FATAL_ERROR "[venmic] CMAKE_JS_INC must be set when building the addon without CMake.js") ++ endif() + endif() + + if (venmic_addon) +diff --git a/addon/CMakeLists.txt b/addon/CMakeLists.txt +index e5922ae..780631a 100644 +--- a/addon/CMakeLists.txt ++++ b/addon/CMakeLists.txt +@@ -29,13 +29,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${src}) + # Setup Dependencies + # -------------------------------------------------------------------------------------------------------- + +-include("../cmake/cpm.cmake") +- +-CPMFindPackage( +- NAME range-v3 +- GIT_TAG 0.12.0 +- GIT_REPOSITORY "https://github.com/ericniebler/range-v3" +-) ++find_package(range-v3 CONFIG REQUIRED) + + target_link_libraries(${PROJECT_NAME} PUBLIC vencord::venmic range-v3::meta) + +diff --git a/src/patchbay.impl.cpp b/src/patchbay.impl.cpp +index deb9212..f3e0c0e 100644 +--- a/src/patchbay.impl.cpp ++++ b/src/patchbay.impl.cpp +@@ -6,6 +6,8 @@ + #include + #include + ++#include ++ + #include + #include + +@@ -393,7 +395,11 @@ namespace vencord + return on_node(id); + } + +- logger::get()->trace("[patchbay] (handle) workaround is active ({})", glz::write_json(options.workaround)); ++ auto workaround_json = glz::write_json(options.workaround); ++ logger::get()->trace( ++ "[patchbay] (handle) workaround is active ({})", ++ workaround_json.value_or(std::string("")) ++ ); + + if (!matches(options.workaround, props)) + {