20 withMiddleClickScroll ? false,
21 # Enables the use of vencord from nixpkgs instead of
22 # letting vesktop manage it's own version
23 withSystemVencord ? false,
25 stdenv.mkDerivation (finalAttrs: {
29 src = fetchFromGitHub {
32 rev = "v${finalAttrs.version}";
33 hash = "sha256-HlT7ddlrMHG1qOCqdaYjuWhJD+5FF1Nkv2sfXLWd07o=";
36 pnpmDeps = pnpm_9.fetchDeps {
43 hash = "sha256-rizJu6v04wFEpJtakC2tfPg/uylz7gAOzJiXvUwdDI4=";
51 ++ lib.optionals stdenv.hostPlatform.isLinux [
52 # vesktop uses venmic, which is a shipped as a prebuilt node module
53 # and needs to be patched
56 # we use a script wrapper here for environment variable expansion at runtime
57 # https://github.com/NixOS/nixpkgs/issues/172583
60 ++ lib.optionals stdenv.hostPlatform.isDarwin [
61 # on macos we don't need to expand variables, so we can use the faster binary wrapper
65 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
72 [ ./disable_update_checking.patch ]
73 ++ lib.optional withSystemVencord (substituteAll {
75 src = ./use_system_vencord.patch;
79 ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
82 # disable code signing on macos
83 # https://github.com/electron-userland/electron-builder/blob/77f977435c99247d5db395895618b150f5006e8f/docs/code-signing.md#how-to-disable-code-signing-during-the-build-process-on-macos
84 postConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
85 export CSC_IDENTITY_AUTO_DISCOVERY=false
88 # electron builds must be writable on darwin
89 preBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
90 cp -r ${electron.dist}/Electron.app .
91 chmod -R u+w Electron.app
98 pnpm exec electron-builder \
100 -c.asarUnpack="**/*.node" \
101 -c.electronDist=${if stdenv.hostPlatform.isDarwin then "." else electron.dist} \
102 -c.electronVersion=${electron.version}
107 postBuild = lib.optionalString stdenv.hostPlatform.isLinux ''
109 ${libicns}/bin/icns2png -x icon.icns
117 + lib.optionalString stdenv.hostPlatform.isLinux ''
118 mkdir -p $out/opt/Vesktop
119 cp -r dist/*unpacked/resources $out/opt/Vesktop/
121 for file in build/icon_*x32.png; do
122 file_suffix=''${file//build\/icon_}
123 install -Dm0644 $file $out/share/icons/hicolor/''${file_suffix//x32.png}/apps/vesktop.png
126 + lib.optionalString stdenv.hostPlatform.isDarwin ''
127 mkdir -p $out/{Applications,bin}
128 mv dist/mac*/Vesktop.App $out/Applications
135 lib.optionalString stdenv.hostPlatform.isLinux ''
136 makeWrapper ${electron}/bin/electron $out/bin/vesktop \
137 --add-flags $out/opt/Vesktop/resources/app.asar \
138 ${lib.optionalString withTTS "--add-flags \"--enable-speech-dispatcher\""} \
139 ${lib.optionalString withMiddleClickScroll "--add-flags \"--enable-blink-features=MiddleClickAutoscroll\""} \
140 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}"
142 + lib.optionalString stdenv.hostPlatform.isDarwin ''
143 makeWrapper $out/Applications/Vesktop.app/Contents/MacOS/Vesktop $out/bin/vesktop
146 desktopItems = lib.optional stdenv.hostPlatform.isLinux (makeDesktopItem {
148 desktopName = "Vesktop";
151 startupWMClass = "Vesktop";
152 genericName = "Internet Messenger";
167 inherit (finalAttrs) pnpmDeps;
168 updateScript = nix-update-script { };
172 description = "Alternate client for Discord with Vencord built-in";
173 homepage = "https://github.com/Vencord/Vesktop";
174 changelog = "https://github.com/Vencord/Vesktop/releases/tag/${finalAttrs.src.rev}";
175 license = lib.licenses.gpl3Only;
176 maintainers = with lib.maintainers; [
182 mainProgram = "vesktop";