diff options
Diffstat (limited to 'pkgs/by-name')
-rw-r--r-- | pkgs/by-name/ve/vesktop/package.nix | 138 | ||||
-rw-r--r-- | pkgs/by-name/ve/vesktop/use_system_vencord.patch | 13 |
2 files changed, 151 insertions, 0 deletions
diff --git a/pkgs/by-name/ve/vesktop/package.nix b/pkgs/by-name/ve/vesktop/package.nix new file mode 100644 index 0000000000000..d25167ebe3083 --- /dev/null +++ b/pkgs/by-name/ve/vesktop/package.nix @@ -0,0 +1,138 @@ +{ lib +, stdenv +, stdenvNoCC +, fetchFromGitHub +, substituteAll +, makeWrapper +, makeDesktopItem +, copyDesktopItems +, vencord +, electron +, pipewire +, libicns +, jq +, moreutils +, nodePackages +}: +stdenv.mkDerivation rec { + pname = "vesktop"; + version = "0.3.3"; + + src = fetchFromGitHub { + owner = "Vencord"; + repo = "Vesktop"; + rev = "v${version}"; + sha256 = "sha256-Njs3tACxUyRolYUtS/q2lITIQnUBFXVXWZEfQ66HpPM="; + }; + + pnpm-deps = stdenvNoCC.mkDerivation { + pname = "${pname}-pnpm-deps"; + inherit src version patches ELECTRON_SKIP_BINARY_DOWNLOAD; + + nativeBuildInputs = [ + jq + moreutils + nodePackages.pnpm + ]; + + # https://github.com/NixOS/nixpkgs/blob/763e59ffedb5c25774387bf99bc725df5df82d10/pkgs/applications/misc/pot/default.nix#L56 + installPhase = '' + export HOME=$(mktemp -d) + + pnpm config set store-dir $out + pnpm install --frozen-lockfile --ignore-script + + rm -rf $out/v3/tmp + for f in $(find $out -name "*.json"); do + sed -i -E -e 's/"checkedAt":[0-9]+,//g' $f + jq --sort-keys . $f | sponge $f + done + ''; + + dontFixup = true; + outputHashMode = "recursive"; + outputHash = "sha256-vInaSLGahRUgvwAeUcI+oV84L+tgNRCmfFpE0aUD4X4="; + }; + + nativeBuildInputs = [ + copyDesktopItems + nodePackages.pnpm + nodePackages.nodejs + makeWrapper + ]; + + patches = [ + (substituteAll { inherit vencord; src = ./use_system_vencord.patch; }) + ]; + + ELECTRON_SKIP_BINARY_DOWNLOAD = 1; + + preBuild = '' + export HOME=$(mktemp -d) + export STORE_PATH=$(mktemp -d) + + cp -r ${pnpm-deps}/* "$STORE_PATH" + chmod -R +w "$STORE_PATH" + + pnpm config set store-dir "$STORE_PATH" + pnpm install --offline --frozen-lockfile --ignore-script + patchShebangs node_modules/{*,.*} + ''; + + postBuild = '' + pnpm build + # using `pnpm exec` here apparently makes it ignore ELECTRON_SKIP_BINARY_DOWNLOAD + ./node_modules/.bin/electron-builder \ + --dir \ + -c.electronDist=${electron}/libexec/electron \ + -c.electronVersion=${electron.version} + ''; + + # this is consistent with other nixpkgs electron packages and upstream, as far as I am aware + # yes, upstream really packages it as "vesktop" but uses "vencorddesktop" file names + installPhase = + let + libPath = lib.makeLibraryPath [ pipewire ]; + in + '' + runHook preInstall + + mkdir -p $out/opt/Vesktop/resources + cp dist/linux-unpacked/resources/app.asar $out/opt/Vesktop/resources + + pushd build + ${libicns}/bin/icns2png -x icon.icns + for file in icon_*x32.png; do + file_suffix=''${file//icon_} + install -Dm0644 $file $out/share/icons/hicolor/''${file_suffix//x32.png}/apps/vencorddesktop.png + done + + makeWrapper ${electron}/bin/electron $out/bin/vencorddesktop \ + --prefix LD_LIBRARY_PATH : ${libPath} \ + --add-flags $out/opt/Vesktop/resources/app.asar \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" + + runHook postInstall + ''; + + desktopItems = [ + (makeDesktopItem { + name = "vencorddesktop"; + desktopName = "Vesktop"; + exec = "vencorddesktop %U"; + icon = "vencorddesktop"; + startupWMClass = "VencordDesktop"; + genericName = "Internet Messenger"; + keywords = [ "discord" "vencord" "electron" "chat" ]; + }) + ]; + + meta = with lib; { + description = "An alternate client for Discord with Vencord built-in"; + homepage = "https://github.com/Vencord/Vesktop"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ getchoo Scrumplex vgskye ]; + platforms = platforms.linux; + mainProgram = "vencorddesktop"; + }; +} diff --git a/pkgs/by-name/ve/vesktop/use_system_vencord.patch b/pkgs/by-name/ve/vesktop/use_system_vencord.patch new file mode 100644 index 0000000000000..242fdcbb21e7b --- /dev/null +++ b/pkgs/by-name/ve/vesktop/use_system_vencord.patch @@ -0,0 +1,13 @@ +diff --git a/src/main/constants.ts b/src/main/constants.ts +index d5c5fa6..a1b32f1 100644 +--- a/src/main/constants.ts ++++ b/src/main/constants.ts +@@ -16,7 +16,7 @@ export const VENCORD_THEMES_DIR = join(DATA_DIR, "themes"); + // needs to be inline require because of circular dependency + // as otherwise "DATA_DIR" (which is used by ./settings) will be uninitialised + export const VENCORD_FILES_DIR = +- (require("./settings") as typeof import("./settings")).Settings.store.vencordDir || join(DATA_DIR, "vencordDist"); ++ (require("./settings") as typeof import("./settings")).Settings.store.vencordDir || "@vencord@"; + + export const USER_AGENT = `Vesktop/${app.getVersion()} (https://github.com/Vencord/Vesktop)`; + |