Merge pull request #310696 from getchoo/pkgs/vesktop/noSystem

vesktop: don't use system vencord by default

authored by K900 and committed by GitHub 2a375993 ddda827f

+107 -71
+107 -71
pkgs/by-name/ve/vesktop/package.nix
··· 1 - { lib 2 - , stdenv 3 - , stdenvNoCC 4 - , fetchFromGitHub 5 - , substituteAll 6 - , makeWrapper 7 - , makeDesktopItem 8 - , copyDesktopItems 9 - , vencord 10 - , electron 11 - , libicns 12 - , jq 13 - , moreutils 14 - , cacert 15 - , nodePackages 16 - , pipewire 17 - , libpulseaudio 18 - , autoPatchelfHook 19 - , withTTS ? true 1 + { 2 + lib, 3 + stdenv, 4 + stdenvNoCC, 5 + fetchFromGitHub, 6 + substituteAll, 7 + makeWrapper, 8 + makeDesktopItem, 9 + copyDesktopItems, 10 + vencord, 11 + electron, 12 + libicns, 13 + jq, 14 + moreutils, 15 + cacert, 16 + nodePackages, 17 + pipewire, 18 + libpulseaudio, 19 + autoPatchelfHook, 20 + withTTS ? true, 20 21 # Enables the use of vencord from nixpkgs instead of 21 22 # letting vesktop manage it's own version 22 - , withSystemVencord ? true 23 + withSystemVencord ? false, 23 24 }: 24 25 stdenv.mkDerivation (finalAttrs: { 25 26 pname = "vesktop"; ··· 38 39 assert lib.versionAtLeast nodePackages.pnpm.version "8.10.0"; 39 40 stdenvNoCC.mkDerivation { 40 41 pname = "${finalAttrs.pname}-pnpm-deps"; 41 - inherit (finalAttrs) src version patches ELECTRON_SKIP_BINARY_DOWNLOAD; 42 + inherit (finalAttrs) 43 + src 44 + version 45 + patches 46 + ELECTRON_SKIP_BINARY_DOWNLOAD 47 + ; 42 48 43 49 nativeBuildInputs = [ 50 + cacert 44 51 jq 45 52 moreutils 46 53 nodePackages.pnpm 47 - cacert 48 54 ]; 49 55 50 - pnpmPatch = builtins.toJSON { 51 - pnpm.supportedArchitectures = { 52 - os = [ "linux" ]; 53 - cpu = [ "x64" "arm64" ]; 54 - }; 55 - }; 56 - 57 - postPatch = '' 58 - mv package.json package.json.orig 59 - jq --raw-output ". * $pnpmPatch" package.json.orig > package.json 60 - ''; 61 - 62 - # https://github.com/NixOS/nixpkgs/blob/763e59ffedb5c25774387bf99bc725df5df82d10/pkgs/applications/misc/pot/default.nix#L56 56 + # inspired by https://github.com/NixOS/nixpkgs/blob/763e59ffedb5c25774387bf99bc725df5df82d10/pkgs/applications/misc/pot/default.nix#L56 57 + # and based on https://github.com/NixOS/nixpkgs/pull/290715 63 58 installPhase = '' 64 - export HOME=$(mktemp -d) 59 + runHook preInstall 65 60 61 + export HOME=$(mktemp -d) 66 62 pnpm config set store-dir $out 67 - pnpm install --frozen-lockfile --ignore-script 63 + # Some packages produce platform dependent outputs. We do not want to cache those in the global store 64 + pnpm config set side-effects-cache false 65 + # pnpm is going to warn us about using --force 66 + # --force allows us to fetch all dependencies including ones that aren't meant for our host platform 67 + pnpm install --force --frozen-lockfile --ignore-script 68 + 69 + ''; 68 70 71 + fixupPhase = '' 72 + runHook preFixup 73 + 74 + # Remove timestamp and sort the json files 69 75 rm -rf $out/v3/tmp 70 76 for f in $(find $out -name "*.json"); do 71 77 sed -i -E -e 's/"checkedAt":[0-9]+,//g' $f 72 78 jq --sort-keys . $f | sponge $f 73 79 done 80 + 81 + runHook postFixup 74 82 ''; 75 83 84 + dontConfigure = true; 76 85 dontBuild = true; 77 - dontFixup = true; 78 86 outputHashMode = "recursive"; 79 - outputHash = "sha256-6ezEBeYmK5va3gCh00YnJzZ77V/Ql7A3l/+csohkz68="; 87 + outputHash = "sha256-PogE8uf3W5cKSCqFHMz7FOvT7ONUP4FiFWGBgtk3UC8="; 80 88 }; 81 89 82 90 nativeBuildInputs = [ 91 + autoPatchelfHook 83 92 copyDesktopItems 93 + makeWrapper 84 94 nodePackages.pnpm 85 95 nodePackages.nodejs 86 - makeWrapper 87 - autoPatchelfHook 88 96 ]; 89 97 90 98 buildInputs = [ 91 - pipewire 92 99 libpulseaudio 100 + pipewire 93 101 stdenv.cc.cc.lib 94 102 ]; 95 103 96 - patches = [ 97 - ./disable_update_checking.patch 98 - ] ++ lib.optional withSystemVencord (substituteAll { inherit vencord; src = ./use_system_vencord.patch; }); 104 + patches = 105 + [ ./disable_update_checking.patch ] 106 + ++ lib.optional withSystemVencord (substituteAll { 107 + inherit vencord; 108 + src = ./use_system_vencord.patch; 109 + }); 99 110 100 111 ELECTRON_SKIP_BINARY_DOWNLOAD = 1; 101 112 102 - preBuild = '' 113 + configurePhase = '' 114 + runHook preConfigure 115 + 103 116 export HOME=$(mktemp -d) 104 117 export STORE_PATH=$(mktemp -d) 105 118 ··· 107 120 chmod -R +w "$STORE_PATH" 108 121 109 122 pnpm config set store-dir "$STORE_PATH" 110 - pnpm install --offline --frozen-lockfile --ignore-script 123 + pnpm install --frozen-lockfile --ignore-script --offline 111 124 patchShebangs node_modules/{*,.*} 125 + 126 + runHook postConfigure 112 127 ''; 113 128 114 - postBuild = '' 129 + buildPhase = '' 130 + runHook preBuild 131 + 115 132 pnpm build 116 133 # using `pnpm exec` here apparently makes it ignore ELECTRON_SKIP_BINARY_DOWNLOAD 117 134 ./node_modules/.bin/electron-builder \ ··· 119 136 -c.asarUnpack="**/*.node" \ 120 137 -c.electronDist=${electron}/libexec/electron \ 121 138 -c.electronVersion=${electron.version} 139 + 140 + runHook postBuild 122 141 ''; 123 142 124 143 # this is consistent with other nixpkgs electron packages and upstream, as far as I am aware 125 - installPhase = 126 - '' 127 - runHook preInstall 144 + installPhase = '' 145 + runHook preInstall 128 146 129 - mkdir -p $out/opt/Vesktop 130 - cp -r dist/linux-*unpacked/resources $out/opt/Vesktop/ 147 + mkdir -p $out/opt/Vesktop 148 + cp -r dist/linux-*unpacked/resources $out/opt/Vesktop/ 131 149 132 - pushd build 133 - ${libicns}/bin/icns2png -x icon.icns 134 - for file in icon_*x32.png; do 135 - file_suffix=''${file//icon_} 136 - install -Dm0644 $file $out/share/icons/hicolor/''${file_suffix//x32.png}/apps/vesktop.png 137 - done 150 + pushd build 151 + ${libicns}/bin/icns2png -x icon.icns 152 + for file in icon_*x32.png; do 153 + file_suffix=''${file//icon_} 154 + install -Dm0644 $file $out/share/icons/hicolor/''${file_suffix//x32.png}/apps/vesktop.png 155 + done 138 156 139 - makeWrapper ${electron}/bin/electron $out/bin/vesktop \ 140 - --add-flags $out/opt/Vesktop/resources/app.asar \ 141 - ${lib.optionalString withTTS "--add-flags \"--enable-speech-dispatcher\""} \ 142 - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}" 157 + makeWrapper ${electron}/bin/electron $out/bin/vesktop \ 158 + --add-flags $out/opt/Vesktop/resources/app.asar \ 159 + ${lib.optionalString withTTS "--add-flags \"--enable-speech-dispatcher\""} \ 160 + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}" 143 161 144 - runHook postInstall 145 - ''; 162 + runHook postInstall 163 + ''; 146 164 147 165 desktopItems = [ 148 166 (makeDesktopItem { ··· 152 170 icon = "vesktop"; 153 171 startupWMClass = "Vesktop"; 154 172 genericName = "Internet Messenger"; 155 - keywords = [ "discord" "vencord" "electron" "chat" ]; 156 - categories = [ "Network" "InstantMessaging" "Chat" ]; 173 + keywords = [ 174 + "discord" 175 + "vencord" 176 + "electron" 177 + "chat" 178 + ]; 179 + categories = [ 180 + "Network" 181 + "InstantMessaging" 182 + "Chat" 183 + ]; 157 184 }) 158 185 ]; 159 186 ··· 161 188 inherit (finalAttrs) pnpmDeps; 162 189 }; 163 190 164 - meta = with lib; { 191 + meta = { 165 192 description = "An alternate client for Discord with Vencord built-in"; 166 193 homepage = "https://github.com/Vencord/Vesktop"; 167 - license = licenses.gpl3Only; 168 - maintainers = with maintainers; [ getchoo Scrumplex vgskye pluiedev ]; 169 - platforms = [ "x86_64-linux" "aarch64-linux" ]; 194 + changelog = "https://github.com/Vencord/Vesktop/releases/tag/${finalAttrs.src.rev}"; 195 + license = lib.licenses.gpl3Only; 196 + maintainers = with lib.maintainers; [ 197 + getchoo 198 + Scrumplex 199 + vgskye 200 + pluiedev 201 + ]; 202 + platforms = [ 203 + "x86_64-linux" 204 + "aarch64-linux" 205 + ]; 170 206 mainProgram = "vesktop"; 171 207 }; 172 208 })