nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 170 lines 4.7 kB view raw
1{ 2 lib, 3 stdenv, 4 callPackage, 5 fetchFromGitHub, 6 makeWrapper, 7 makeDesktopItem, 8 copyDesktopItems, 9 electron, 10 python3Packages, 11 pipewire, 12 libpulseaudio, 13 autoPatchelfHook, 14 bun, 15 nodejs, 16 withTTS ? true, 17 withMiddleClickScroll ? false, 18}: 19stdenv.mkDerivation (finalAttrs: { 20 pname = "equibop"; 21 version = "3.1.7"; 22 23 src = fetchFromGitHub { 24 owner = "Equicord"; 25 repo = "Equibop"; 26 tag = "v${finalAttrs.version}"; 27 hash = "sha256-AzXBANUcm/DYYkNlO7q++/Dx826o5Hg/1cYJ84rMY0U="; 28 }; 29 30 postPatch = '' 31 substituteInPlace scripts/build/build.mts \ 32 --replace-fail 'gitHash = execSync("git rev-parse HEAD", { encoding: "utf-8" }).trim();' 'gitHash = "${finalAttrs.src.hash}"' 33 34 # disable auto updates 35 substituteInPlace src/main/updater.ts \ 36 --replace-fail 'const isOutdated = autoUpdater.checkForUpdates().then(res => Boolean(res?.isUpdateAvailable));' 'const isOutdated = false;' 37 ''; 38 39 node-modules = callPackage ./node-modules.nix { }; 40 41 nativeBuildInputs = [ 42 bun 43 nodejs 44 # XXX: Equibop *does not* ship venmic as a prebuilt node module. The package 45 # seems to build with or without this hook, but I (NotAShelf) don't have the 46 # time to test the consequences of removing this hook. Please open a pull 47 # request if this bothers you in some way. 48 autoPatchelfHook 49 copyDesktopItems 50 # we use a script wrapper here for environment variable expansion at runtime 51 # https://github.com/NixOS/nixpkgs/issues/172583 52 makeWrapper 53 ]; 54 55 buildInputs = [ 56 libpulseaudio 57 pipewire 58 (lib.getLib stdenv.cc.cc) 59 ]; 60 61 configurePhase = '' 62 runHook preConfigure 63 64 cp -R ${finalAttrs.node-modules} node_modules 65 66 runHook postConfigure 67 ''; 68 69 # electron builds must be writable to support electron fuses 70 preBuild = 71 lib.optionalString stdenv.hostPlatform.isDarwin '' 72 cp -r ${electron.dist}/Electron.app . 73 chmod -R u+w Electron.app 74 '' 75 + lib.optionalString stdenv.hostPlatform.isLinux '' 76 cp -r ${electron.dist} electron-dist 77 chmod -R u+w electron-dist 78 ''; 79 80 buildPhase = '' 81 runHook preBuild 82 83 bun run build 84 85 bun run compileArrpc 86 87 # can't run it via bunx / npx since fixupPhase was skipped for node_modules 88 node node_modules/electron-builder/out/cli/cli.js \ 89 --dir \ 90 -c.electronDist=${if stdenv.hostPlatform.isDarwin then "." else "electron-dist"} \ 91 -c.electronVersion=${electron.version} \ 92 -c.npmRebuild=false 93 94 runHook postBuild 95 ''; 96 97 postBuild = '' 98 pushd build 99 ${lib.getExe' python3Packages.icnsutil "icnsutil"} e icon.icns 100 popd 101 ''; 102 103 installPhase = '' 104 runHook preInstall 105 mkdir -p $out/opt/Equibop 106 cp -r dist/*unpacked/resources $out/opt/Equibop/ 107 108 for file in build/icon.icns.export/*.png; do 109 base=''${file##*/} 110 size=''${base/x*/} 111 install -Dm0644 $file $out/share/icons/hicolor/''${size}x''${size}/apps/equibop.png 112 done 113 114 install -Dm0644 build/icon.svg $out/share/icons/hicolor/scalable/apps/equibop.svg 115 116 runHook postInstall 117 ''; 118 119 postFixup = '' 120 makeWrapper ${electron}/bin/electron $out/bin/equibop \ 121 --add-flags $out/opt/Equibop/resources/app.asar \ 122 ${lib.optionalString withTTS "--add-flags \"--enable-speech-dispatcher\""} \ 123 ${lib.optionalString withMiddleClickScroll "--add-flags \"--enable-blink-features=MiddleClickAutoscroll\""} \ 124 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" 125 ''; 126 127 desktopItems = makeDesktopItem { 128 name = "equibop"; 129 desktopName = "Equibop"; 130 exec = "equibop %U"; 131 icon = "equibop"; 132 startupWMClass = "Equibop"; 133 genericName = "Internet Messenger"; 134 keywords = [ 135 "discord" 136 "equibop" 137 "electron" 138 "chat" 139 ]; 140 categories = [ 141 "Network" 142 "InstantMessaging" 143 "Chat" 144 ]; 145 }; 146 147 passthru = { 148 # fails to update node-modules FOD :/ 149 # updateScript = nix-update-script { 150 # extraArgs = [ 151 # "--subpackage" 152 # "node-modules" 153 # ]; 154 # }; 155 }; 156 157 meta = { 158 description = "Custom Discord App aiming to give you better performance and improve linux support"; 159 homepage = "https://github.com/Equicord/Equibop"; 160 changelog = "https://github.com/Equicord/Equibop/releases/tag/v${finalAttrs.version}"; 161 license = lib.licenses.gpl3Only; 162 maintainers = with lib.maintainers; [ 163 NotAShelf 164 rexies 165 ]; 166 mainProgram = "equibop"; 167 # I am not confident in my ability to support Darwin, please PR if this is important to you 168 platforms = lib.platforms.linux; 169 }; 170})