Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

legcord: refactor; 1.1.0 -> 1.1.1 #390517

Merged
merged 3 commits into from
Mar 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 67 additions & 24 deletions pkgs/by-name/le/legcord/package.nix
Original file line number Diff line number Diff line change
@@ -2,48 +2,70 @@
lib,
stdenv,
fetchFromGitHub,
pnpm_9,
pnpm,
nodejs,
electron_34,
electron,
makeWrapper,
copyDesktopItems,
makeDesktopItem,
autoPatchelfHook,
pipewire,
libpulseaudio,
nix-update-script,
}:
stdenv.mkDerivation rec {

stdenv.mkDerivation (finalAttrs: {
pname = "legcord";
version = "1.1.0";
version = "1.1.1";

src = fetchFromGitHub {
owner = "Legcord";
repo = "Legcord";
rev = "v${version}";
hash = "sha256-IfRjblC3L6A7HgeEDeDrRxtIMvWQB3P7mpq5bhaHWqk=";
tag = "v${finalAttrs.version}";
hash = "sha256-0RbLvRCvy58HlOhHLcAoErRFgYxjWrKFQ6DPJD50c5Q=";
};

nativeBuildInputs = [
pnpm_9.configHook
pnpm.configHook
nodejs
# we use a script wrapper here for environment variable expansion at runtime
# https://github.com/NixOS/nixpkgs/issues/172583
makeWrapper
copyDesktopItems
# legcord uses venmic, which is a shipped as a prebuilt node module
# and needs to be patched
autoPatchelfHook
];

pnpmDeps = pnpm_9.fetchDeps {
inherit pname version src;
hash = "sha256-LbHYY97HsNF9cBQzAfFw+A/tLf27y3he9Bbw9H3RKK4=";
};
buildInputs = [
libpulseaudio
pipewire
(lib.getLib stdenv.cc.cc)
];

ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-zAf3EGIt/BWSZ9BMHWWVPWo3m+whnl/p+SahmpdLoZ4=";
};

buildPhase = ''
runHook preBuild

pnpm build

npm exec electron-builder -- \
# Replicating the build step to copy venmic from the vendored node module manually,
# since the install script does not do this for whatever reason
cp ./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-x64/node-napi-v7.node ./dist/venmic-x64.node
cp ./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node ./dist/venmic-arm64.node

# Patch venmic before putting it into the ASAR archive
autoPatchelf ./dist

pnpm exec electron-builder \
--dir \
-c.electronDist="${electron_34.dist}" \
-c.electronVersion="${electron_34.version}"
-c.asarUnpack="**/*.node" \
-c.electronDist="${electron.dist}" \
-c.electronVersion="${electron.version}"

runHook postBuild
'';
@@ -56,44 +78,65 @@ stdenv.mkDerivation rec {

install -Dm644 "build/icon.png" "$out/share/icons/hicolor/256x256/apps/legcord.png"

makeShellWrapper "${lib.getExe electron_34}" "$out/bin/legcord" \
# use makeShellWrapper (instead of the makeBinaryWrapper provided by wrapGAppsHook3) for proper shell variable expansion
# see https://github.com/NixOS/nixpkgs/issues/172583
makeShellWrapper "${lib.getExe electron}" "$out/bin/legcord" \
--add-flags "$out/share/lib/legcord/resources/app.asar" \
"''${gappsWrapperArgs[@]}" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=UseOzonePlatform,WaylandWindowDecorations,WebRTCPipeWireCapturer --enable-wayland-ime=true}}" \
--set-default ELECTRON_IS_DEV 0 \
--inherit-argv0

runHook postInstall
'';

env = {
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
};

desktopItems = [
(makeDesktopItem {
name = "legcord";
genericName = "Internet Messenger";
desktopName = "Legcord";
exec = "legcord %U";
icon = "legcord";
comment = meta.description;
categories = [ "Network" ];
comment = finalAttrs.meta.description;
keywords = [
"discord"
"vencord"
"electron"
"chat"
];
categories = [
"Network"
"InstantMessaging"
"Chat"
];
startupWMClass = "Legcord";
terminal = false;
})
];

passthru.updateScript = nix-update-script { };
passthru = {
inherit (finalAttrs) pnpmDeps;
updateScript = nix-update-script { };
};

meta = with lib; {
meta = {
description = "Lightweight, alternative desktop client for Discord";
homepage = "https://legcord.app";
downloadPage = "https://github.com/Legcord/Legcord";
license = licenses.osl3;
maintainers = with maintainers; [
license = lib.licenses.osl3;
maintainers = with lib.maintainers; [
wrmilling
water-sucks
nyabinary
];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
mainProgram = "legcord";
};
}
})