Skip to content

Commit 66fa3e2

Browse files
authored
legcord: refactor; 1.1.0 -> 1.1.1 (#390517)
2 parents 6e78c78 + 4d50cf2 commit 66fa3e2

File tree

1 file changed

+67
-24
lines changed

1 file changed

+67
-24
lines changed

pkgs/by-name/le/legcord/package.nix

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,70 @@
22
lib,
33
stdenv,
44
fetchFromGitHub,
5-
pnpm_9,
5+
pnpm,
66
nodejs,
7-
electron_34,
7+
electron,
88
makeWrapper,
99
copyDesktopItems,
1010
makeDesktopItem,
11+
autoPatchelfHook,
12+
pipewire,
13+
libpulseaudio,
1114
nix-update-script,
1215
}:
13-
stdenv.mkDerivation rec {
16+
17+
stdenv.mkDerivation (finalAttrs: {
1418
pname = "legcord";
15-
version = "1.1.0";
19+
version = "1.1.1";
1620

1721
src = fetchFromGitHub {
1822
owner = "Legcord";
1923
repo = "Legcord";
20-
rev = "v${version}";
21-
hash = "sha256-IfRjblC3L6A7HgeEDeDrRxtIMvWQB3P7mpq5bhaHWqk=";
24+
tag = "v${finalAttrs.version}";
25+
hash = "sha256-0RbLvRCvy58HlOhHLcAoErRFgYxjWrKFQ6DPJD50c5Q=";
2226
};
2327

2428
nativeBuildInputs = [
25-
pnpm_9.configHook
29+
pnpm.configHook
2630
nodejs
31+
# we use a script wrapper here for environment variable expansion at runtime
32+
# https://github.com/NixOS/nixpkgs/issues/172583
2733
makeWrapper
2834
copyDesktopItems
35+
# legcord uses venmic, which is a shipped as a prebuilt node module
36+
# and needs to be patched
37+
autoPatchelfHook
2938
];
3039

31-
pnpmDeps = pnpm_9.fetchDeps {
32-
inherit pname version src;
33-
hash = "sha256-LbHYY97HsNF9cBQzAfFw+A/tLf27y3he9Bbw9H3RKK4=";
34-
};
40+
buildInputs = [
41+
libpulseaudio
42+
pipewire
43+
(lib.getLib stdenv.cc.cc)
44+
];
3545

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

3851
buildPhase = ''
3952
runHook preBuild
4053
4154
pnpm build
4255
43-
npm exec electron-builder -- \
56+
# Replicating the build step to copy venmic from the vendored node module manually,
57+
# since the install script does not do this for whatever reason
58+
cp ./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-x64/node-napi-v7.node ./dist/venmic-x64.node
59+
cp ./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node ./dist/venmic-arm64.node
60+
61+
# Patch venmic before putting it into the ASAR archive
62+
autoPatchelf ./dist
63+
64+
pnpm exec electron-builder \
4465
--dir \
45-
-c.electronDist="${electron_34.dist}" \
46-
-c.electronVersion="${electron_34.version}"
66+
-c.asarUnpack="**/*.node" \
67+
-c.electronDist="${electron.dist}" \
68+
-c.electronVersion="${electron.version}"
4769
4870
runHook postBuild
4971
'';
@@ -56,44 +78,65 @@ stdenv.mkDerivation rec {
5678
5779
install -Dm644 "build/icon.png" "$out/share/icons/hicolor/256x256/apps/legcord.png"
5880
59-
makeShellWrapper "${lib.getExe electron_34}" "$out/bin/legcord" \
81+
# use makeShellWrapper (instead of the makeBinaryWrapper provided by wrapGAppsHook3) for proper shell variable expansion
82+
# see https://github.com/NixOS/nixpkgs/issues/172583
83+
makeShellWrapper "${lib.getExe electron}" "$out/bin/legcord" \
6084
--add-flags "$out/share/lib/legcord/resources/app.asar" \
6185
"''${gappsWrapperArgs[@]}" \
62-
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
86+
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=UseOzonePlatform,WaylandWindowDecorations,WebRTCPipeWireCapturer --enable-wayland-ime=true}}" \
6387
--set-default ELECTRON_IS_DEV 0 \
6488
--inherit-argv0
6589
6690
runHook postInstall
6791
'';
6892

93+
env = {
94+
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
95+
};
96+
6997
desktopItems = [
7098
(makeDesktopItem {
7199
name = "legcord";
100+
genericName = "Internet Messenger";
72101
desktopName = "Legcord";
73102
exec = "legcord %U";
74103
icon = "legcord";
75-
comment = meta.description;
76-
categories = [ "Network" ];
104+
comment = finalAttrs.meta.description;
105+
keywords = [
106+
"discord"
107+
"vencord"
108+
"electron"
109+
"chat"
110+
];
111+
categories = [
112+
"Network"
113+
"InstantMessaging"
114+
"Chat"
115+
];
77116
startupWMClass = "Legcord";
78117
terminal = false;
79118
})
80119
];
81120

82-
passthru.updateScript = nix-update-script { };
121+
passthru = {
122+
inherit (finalAttrs) pnpmDeps;
123+
updateScript = nix-update-script { };
124+
};
83125

84-
meta = with lib; {
126+
meta = {
85127
description = "Lightweight, alternative desktop client for Discord";
86128
homepage = "https://legcord.app";
87129
downloadPage = "https://github.com/Legcord/Legcord";
88-
license = licenses.osl3;
89-
maintainers = with maintainers; [
130+
license = lib.licenses.osl3;
131+
maintainers = with lib.maintainers; [
90132
wrmilling
91133
water-sucks
134+
nyabinary
92135
];
93136
platforms = [
94137
"x86_64-linux"
95138
"aarch64-linux"
96139
];
97140
mainProgram = "legcord";
98141
};
99-
}
142+
})

0 commit comments

Comments
 (0)