baidunetdisk, electron_11: add like nur.xddxdd

This commit is contained in:
ZMSUN 2025-10-23 14:58:02 +08:00
parent 234d6c0325
commit 52a60470f2
Signed by: zm
GPG key ID: 9887E5061F495C4C
3 changed files with 319 additions and 0 deletions

View file

@ -0,0 +1,124 @@
{
stdenv,
makeWrapper,
lib,
electron_11,
makeDesktopItem,
copyDesktopItems,
dpkg,
fetchurl,
# BaiduNetdisk dependencies
libappindicator,
libdbusmenu,
libglvnd,
}:
################################################################################
# Mostly based on baidnetdisk-electron package from AUR:
# https://aur.archlinux.org/packages/baidunetdisk-electron
################################################################################
let
libraries = [
stdenv.cc.cc.lib
libappindicator
libdbusmenu
libglvnd
];
dist = stdenv.mkDerivation (finalAttrs: {
pname = "baidunetdisk";
version = "4.17.7";
src = fetchurl {
url = "http://wppkg.baidupcs.com/issue/netdisk/Linuxguanjia/4.17.7/baidunetdisk_4.17.7_amd64.deb";
hash = "sha256-UOwY8FYmoT9X7wNGMEFtSBaCvBAYU58zOX1ccbxlOz0=";
};
dontFixup = true;
nativeBuildInputs = [ dpkg ];
unpackPhase = ''
dpkg -x $src .
'';
installPhase = ''
mkdir -p $out/bin
cp -r opt/baidunetdisk/* $out
pushd $out
rm -rf \
baidunetdisk \
baidunetdisk.desktop \
baiduNetdiskContext.conf \
baidunetdiskv.desktop \
bin \
binswiftshader \
chrome_100_percent.pak \
chrome_200_percent.pak \
chrome-sandbox \
icudtl.dat \
libEGL.so \
libffmpeg.so \
libGLESv2.so \
libvk_swiftshader.so \
libvulkan.so \
LICENSE.* \
locales \
resources.pak \
resources/8bb88996964c4e3202fecaaa5605af03 \
resources/default.db \
resources/dir.icns \
resources/resource.db \
snapshot_blob.bin \
v8_context_snapshot.bin \
vk_swiftshader_icd.json
popd
'';
});
in
stdenv.mkDerivation (finalAttrs: {
pname = "baidunetdisk";
version = "4.17.7";
dontUnpack = true;
nativeBuildInputs = [
makeWrapper
copyDesktopItems
];
postInstall = ''
mkdir -p $out/bin
makeWrapper ${electron_11}/bin/electron $out/bin/baidunetdisk \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libraries}:${dist}" \
--add-flags "--no-sandbox" \
--add-flags "${dist}/resources/app.asar"
install -Dm644 ${dist}/baidunetdisk.svg $out/share/icons/hicolor/scalable/apps/baidunetdisk.svg
'';
desktopItems = [
(makeDesktopItem {
name = "baidunetdisk";
desktopName = "Baidu Netdisk";
exec = "baidunetdisk %U";
terminal = false;
icon = "baidunetdisk";
startupWMClass = "baidunetdisk";
comment = "Baidu Netdisk";
mimeTypes = [ "x-scheme-handler/baiduyunguanjia" ];
categories = [ "Network" ];
extraConfig = {
"Name[zh_CN]" = "";
"Name[zh_TW]" = "";
"Comment[zh_CN]" = "";
"Comment[zh_TW]" = "";
};
})
];
meta = {
description = "Baidu Netdisk";
homepage = "https://pan.baidu.com/";
platforms = [ "x86_64-linux" ];
license = lib.licenses.unfreeRedistributable;
mainProgram = "baidunetdisk";
};
})

View file

@ -0,0 +1,14 @@
{ callPackage }:
let
mkElectron = callPackage ./generic.nix { };
in
mkElectron "11.5.0" {
x86_64-linux = "613ef8ac00c5abda425dfa48778a68f58a2e9c7c1f82539bb1a41afabbd6193f";
x86_64-darwin = "32937dca29fc397f0b15dbab720ed3edb88eee24f00f911984b307bf12dc8fd5";
i686-linux = "cd154c56d02d7b1f16e2bcd5650bddf0de9141fdbb8248adc64f6d607e5fb725";
armv7l-linux = "3f5a41037aaad658051d8bc8b04e8dece72b729dd1a1ed8311b365daa8deea76";
aarch64-linux = "f698a7743962f553fe36673f1c85bccbd918efba8f6dca3a3df39d41c8e2de3e";
aarch64-darwin = "749fb6bd676e174de66845b8ac959985f30a773dcb2c05553890bd99b94c9d60";
headers = "1zkdgpjrh1dc9j8qyrrrh49v24960yhvwi2c530qbpf2azgqj71b";
}

View file

@ -0,0 +1,181 @@
# nixpkgs/pkgs/development/tools/electron/binary/generic.nix
{
lib,
stdenv,
makeWrapper,
fetchurl,
wrapGAppsHook,
glib,
gtk3,
unzip,
at-spi2-atk,
libdrm,
mesa,
libxkbcommon,
libGL,
alsa-lib,
cairo,
cups,
dbus,
expat,
gdk-pixbuf,
nss,
nspr,
xorg,
pango,
systemd,
pciutils,
}:
version: hashes:
let
pname = "electron";
meta = {
maintainers = with lib.maintainers; [ xddxdd ];
description = "Cross platform desktop application shell";
homepage = "https://github.com/electron/electron";
license = lib.licenses.mit;
mainProgram = "electron";
platforms =
[
"x86_64-darwin"
"x86_64-linux"
"armv7l-linux"
"aarch64-linux"
]
++ lib.optionals (lib.versionAtLeast version "11.0.0") [ "aarch64-darwin" ]
++ lib.optionals (lib.versionOlder version "19.0.0") [ "i686-linux" ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
knownVulnerabilities = lib.optional (lib.versionOlder version "27.0.0") "Electron version ${version} is EOL";
};
fetcher =
vers: tag: hash:
fetchurl {
url = "https://github.com/electron/electron/releases/download/v${vers}/electron-v${vers}-${tag}.zip";
sha256 = hash;
};
headersFetcher =
vers: hash:
fetchurl {
url = "https://artifacts.electronjs.org/headers/dist/v${vers}/node-v${vers}-headers.tar.gz";
sha256 = hash;
};
tags =
{
x86_64-linux = "linux-x64";
armv7l-linux = "linux-armv7l";
aarch64-linux = "linux-arm64";
x86_64-darwin = "darwin-x64";
}
// lib.optionalAttrs (lib.versionAtLeast version "11.0.0") { aarch64-darwin = "darwin-arm64"; }
// lib.optionalAttrs (lib.versionOlder version "19.0.0") { i686-linux = "linux-ia32"; };
get = as: platform: as.${platform.system} or (throw "Unsupported system: ${platform.system}");
common = platform: {
inherit pname version meta;
src = fetcher version (get tags platform) (get hashes platform);
passthru.headers = headersFetcher version hashes.headers;
};
electronLibPath = lib.makeLibraryPath (
[
alsa-lib
at-spi2-atk
cairo
cups
dbus
expat
gdk-pixbuf
glib
gtk3
nss
nspr
xorg.libX11
xorg.libxcb
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libxkbfile
pango
pciutils
stdenv.cc.cc.lib
systemd
]
++ lib.optionals (lib.versionAtLeast version "9.0.0") [
libdrm
mesa
]
++ lib.optionals (lib.versionOlder version "10.0.0") [ xorg.libXScrnSaver ]
++ lib.optionals (lib.versionAtLeast version "11.0.0") [ libxkbcommon ]
++ lib.optionals (lib.versionAtLeast version "12.0.0") [ xorg.libxshmfence ]
++ lib.optionals (lib.versionAtLeast version "17.0.0") [ libGL ]
);
linux = {
buildInputs = [
glib
gtk3
];
nativeBuildInputs = [
unzip
makeWrapper
wrapGAppsHook
];
dontUnpack = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/libexec/electron $out/bin
unzip -d $out/libexec/electron $src
ln -s $out/libexec/electron/electron $out/bin
chmod u-x $out/libexec/electron/*.so*
runHook postInstall
'';
postFixup = ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${electronLibPath}:$out/libexec/electron" \
$out/libexec/electron/.electron-wrapped \
${lib.optionalString (lib.versionAtLeast version "15.0.0") "$out/libexec/electron/.chrome_crashpad_handler-wrapped"}
# patch libANGLE
patchelf \
--set-rpath "${
lib.makeLibraryPath [
libGL
pciutils
]
}" \
$out/libexec/electron/lib*GL*
'';
};
darwin = {
nativeBuildInputs = [
makeWrapper
unzip
];
buildCommand = ''
mkdir -p $out/Applications
unzip $src
mv Electron.app $out/Applications
mkdir -p $out/bin
makeWrapper $out/Applications/Electron.app/Contents/MacOS/Electron $out/bin/electron
'';
};
in
stdenv.mkDerivation ((common stdenv.hostPlatform) // (if stdenv.isDarwin then darwin else linux))