nixpkgs/pkgs/by-name/ve/vesktop/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

176 lines
4.7 KiB
Nix
Raw Normal View History

2023-10-14 07:09:57 +00:00
{ lib
, stdenv
, stdenvNoCC
, fetchFromGitHub
, substituteAll
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, vencord
, electron
, pipewire
, libpulseaudio
2023-10-14 07:09:57 +00:00
, libicns
2023-12-14 02:11:50 +00:00
, libnotify
2023-10-14 07:09:57 +00:00
, jq
, moreutils
, cacert
2023-10-14 07:09:57 +00:00
, nodePackages
2024-01-16 03:49:18 +00:00
, speechd
, withTTS ? true
2024-01-10 06:14:45 +00:00
# Enables the use of vencord from nixpkgs instead of
# letting vesktop manage it's own version
, withSystemVencord ? true
2023-10-14 07:09:57 +00:00
}:
stdenv.mkDerivation (finalAttrs: {
2023-10-14 07:09:57 +00:00
pname = "vesktop";
2024-01-16 02:23:31 +00:00
version = "1.5.0";
2023-10-14 07:09:57 +00:00
src = fetchFromGitHub {
owner = "Vencord";
repo = "Vesktop";
rev = "v${finalAttrs.version}";
2024-01-16 02:23:31 +00:00
hash = "sha256-27998q9wbaNP1xYY+KHTBeJRfR6Q/K0LNdbRb3YHC6c=";
2023-10-14 07:09:57 +00:00
};
# NOTE: This requires pnpm 8.10.0 or newer
# https://github.com/pnpm/pnpm/pull/7214
pnpmDeps =
assert lib.versionAtLeast nodePackages.pnpm.version "8.10.0";
stdenvNoCC.mkDerivation {
pname = "${finalAttrs.pname}-pnpm-deps";
inherit (finalAttrs) src version patches ELECTRON_SKIP_BINARY_DOWNLOAD;
nativeBuildInputs = [
jq
moreutils
nodePackages.pnpm
cacert
];
pnpmPatch = builtins.toJSON {
pnpm.supportedArchitectures = {
os = [ "linux" ];
cpu = [ "x64" "arm64" ];
};
};
postPatch = ''
mv package.json package.json.orig
jq --raw-output ". * $pnpmPatch" package.json.orig > package.json
'';
# 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
'';
dontBuild = true;
dontFixup = true;
outputHashMode = "recursive";
2024-01-16 02:23:31 +00:00
outputHash = "sha256-cnk+KFdvsgG1wGDib7zgIS6/RkrR5EYAHtHcrFSU0Es=";
};
2023-10-14 07:09:57 +00:00
nativeBuildInputs = [
copyDesktopItems
nodePackages.pnpm
nodePackages.nodejs
makeWrapper
];
patches = [
./disable_update_checking.patch
2024-01-10 06:14:45 +00:00
] ++ lib.optional withSystemVencord (substituteAll { inherit vencord; src = ./use_system_vencord.patch; });
2023-10-14 07:09:57 +00:00
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
preBuild = ''
export HOME=$(mktemp -d)
export STORE_PATH=$(mktemp -d)
cp -Tr "$pnpmDeps" "$STORE_PATH"
2023-10-14 07:09:57 +00:00
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
installPhase =
let
# this is mainly required for venmic
2024-01-16 03:49:18 +00:00
libPath = lib.makeLibraryPath ([
libpulseaudio
2023-12-14 02:11:50 +00:00
libnotify
pipewire
stdenv.cc.cc.lib
2024-01-16 03:49:18 +00:00
] ++ lib.optional withTTS speechd);
2023-10-14 07:09:57 +00:00
in
''
runHook preInstall
mkdir -p $out/opt/Vesktop/resources
2023-11-02 22:52:05 +00:00
cp dist/linux-*unpacked/resources/app.asar $out/opt/Vesktop/resources
2023-10-14 07:09:57 +00:00
pushd build
${libicns}/bin/icns2png -x icon.icns
for file in icon_*x32.png; do
file_suffix=''${file//icon_}
2024-01-16 02:23:31 +00:00
install -Dm0644 $file $out/share/icons/hicolor/''${file_suffix//x32.png}/apps/vesktop.png
2023-10-14 07:09:57 +00:00
done
2024-01-16 02:23:31 +00:00
makeWrapper ${electron}/bin/electron $out/bin/vesktop \
2023-10-14 07:09:57 +00:00
--prefix LD_LIBRARY_PATH : ${libPath} \
--add-flags $out/opt/Vesktop/resources/app.asar \
2024-01-16 03:49:18 +00:00
${lib.optionalString withTTS "--add-flags \"--enable-speech-dispatcher\""} \
2023-10-14 07:09:57 +00:00
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
2024-01-16 02:23:31 +00:00
name = "vesktop";
2023-10-14 07:09:57 +00:00
desktopName = "Vesktop";
2024-01-16 02:23:31 +00:00
exec = "vesktop %U";
icon = "vesktop";
startupWMClass = "Vesktop";
2023-10-14 07:09:57 +00:00
genericName = "Internet Messenger";
keywords = [ "discord" "vencord" "electron" "chat" ];
2023-11-26 12:31:38 +00:00
categories = [ "Network" "InstantMessaging" "Chat" ];
2023-10-14 07:09:57 +00:00
})
];
passthru = {
inherit (finalAttrs) pnpmDeps;
};
2023-10-14 07:09:57 +00:00
meta = with lib; {
description = "An alternate client for Discord with Vencord built-in";
homepage = "https://github.com/Vencord/Vesktop";
license = licenses.gpl3Only;
2023-11-03 13:42:34 +00:00
maintainers = with maintainers; [ getchoo Scrumplex vgskye pluiedev ];
platforms = [ "x86_64-linux" "aarch64-linux" ];
2024-01-16 02:23:31 +00:00
mainProgram = "vesktop";
2023-10-14 07:09:57 +00:00
};
})