Merge pull request #313493 from TomaSajt/jitsi-meet-electron

jitsi-meet-electron: fix darwin build

authored by lassulus and committed by GitHub b1eff03c 77874773

+45 -12
+45 -12
pkgs/applications/networking/instant-messengers/jitsi-meet-electron/default.nix
··· 1 1 { lib 2 + , stdenv 2 3 , buildNpmPackage 3 4 , fetchFromGitHub 4 5 , copyDesktopItems ··· 9 10 , libXi 10 11 , libXtst 11 12 , zlib 13 + , darwin 12 14 , electron 13 15 }: 14 16 17 + let 18 + inherit (darwin.apple_sdk.frameworks) Carbon CoreFoundation ApplicationServices OpenGL; 19 + 20 + electronDist = electron + (if stdenv.isDarwin then "/Applications" else "/libexec/electron"); 21 + in 15 22 buildNpmPackage rec { 16 23 pname = "jitsi-meet-electron"; 17 24 version = "2024.3.0"; ··· 24 31 }; 25 32 26 33 nativeBuildInputs = [ 34 + makeWrapper 35 + ] ++ lib.optionals stdenv.isLinux [ 27 36 copyDesktopItems 28 - makeWrapper 29 37 ]; 30 38 31 39 # robotjs node-gyp dependencies 32 - buildInputs = [ 40 + buildInputs = lib.optionals stdenv.isLinux [ 33 41 libpng 34 42 libX11 35 43 libXi 36 44 libXtst 37 45 zlib 46 + ] ++ lib.optionals stdenv.isDarwin [ 47 + Carbon 48 + CoreFoundation 49 + ApplicationServices 50 + OpenGL 38 51 ]; 39 52 40 53 npmDepsHash = "sha256-KanG8y+tYzswCCXjSkOlk+p9XKaouP2Z7IhsD5bDtRk="; ··· 43 56 44 57 env.ELECTRON_SKIP_BINARY_DOWNLOAD = 1; 45 58 59 + # disable code signing on Darwin 60 + env.CSC_IDENTITY_AUTO_DISCOVERY = "false"; 61 + 46 62 preBuild = '' 47 63 # remove some prebuilt binaries 48 64 find node_modules -type d -name prebuilds -exec rm -r {} + 65 + 66 + # don't force both darwin architectures together 67 + substituteInPlace node_modules/@jitsi/robotjs/binding.gyp \ 68 + --replace-fail "-arch x86_64" "" \ 69 + --replace-fail "-arch arm64" "" 49 70 ''; 50 71 51 72 postBuild = '' 52 - # generate .asar file 73 + cp -r ${electronDist} electron-dist 74 + chmod -R u+w electron-dist 75 + 76 + # npmRebuild is needed because robotjs won't be built on darwin otherwise 53 77 # asarUnpack makes sure to unwrap binaries so that nix can see the RPATH 54 78 npm exec electron-builder -- \ 55 79 --dir \ 80 + -c.npmRebuild=true \ 56 81 -c.asarUnpack="**/*.node" \ 57 - -c.electronDist=${electron}/libexec/electron \ 82 + -c.electronDist=electron-dist \ 58 83 -c.electronVersion=${electron.version} 59 84 ''; 60 85 61 86 installPhase = '' 62 87 runHook preInstall 63 88 64 - mkdir -p $out/share/jitsi-meet-electron 65 - cp -r dist/*-unpacked/{locales,resources{,.pak}} $out/share/jitsi-meet-electron 89 + ${lib.optionalString stdenv.isLinux '' 90 + mkdir -p $out/share/jitsi-meet-electron 91 + cp -r dist/*-unpacked/{locales,resources{,.pak}} $out/share/jitsi-meet-electron 66 92 67 - makeWrapper ${lib.getExe electron} $out/bin/jitsi-meet-electron \ 68 - --add-flags $out/share/jitsi-meet-electron/resources/app.asar \ 69 - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 70 - --set-default ELECTRON_IS_DEV 0 \ 71 - --inherit-argv0 93 + makeWrapper ${lib.getExe electron} $out/bin/jitsi-meet-electron \ 94 + --add-flags $out/share/jitsi-meet-electron/resources/app.asar \ 95 + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 96 + --set-default ELECTRON_IS_DEV 0 \ 97 + --inherit-argv0 72 98 73 - install -Dm644 resources/icons/512x512.png $out/share/icons/hicolor/512x512/apps/jitsi-meet-electron.png 99 + install -Dm644 resources/icons/512x512.png $out/share/icons/hicolor/512x512/apps/jitsi-meet-electron.png 100 + ''} 101 + 102 + ${lib.optionalString stdenv.isDarwin '' 103 + mkdir -p $out/Applications 104 + cp -r dist/mac*/"Jitsi Meet.app" $out/Applications 105 + makeWrapper "$out/Applications/Jitsi Meet.app/Contents/MacOS/Jitsi Meet" $out/bin/jitsi-meet-electron 106 + ''} 74 107 75 108 runHook postInstall 76 109 '';