nixpkgs-suyu/pkgs/development/tools/electron/generic.nix

86 lines
2.4 KiB
Nix
Raw Normal View History

2020-05-21 19:41:22 +02:00
{ stdenv, libXScrnSaver, makeWrapper, fetchurl, wrapGAppsHook, glib, gtk3, unzip, atomEnv, libuuid, at-spi2-atk, at-spi2-core, libdrm, mesa }:
2019-08-09 18:45:58 +02:00
version: hashes:
2019-08-09 18:45:58 +02:00
let
name = "electron-${version}";
meta = with stdenv.lib; {
description = "Cross platform desktop application shell";
homepage = "https://github.com/electron/electron";
2019-08-09 18:45:58 +02:00
license = licenses.mit;
2020-05-19 15:01:09 +02:00
maintainers = with maintainers; [ travisbhartwell manveru prusnak ];
2019-08-09 18:45:58 +02:00
platforms = [ "x86_64-darwin" "x86_64-linux" "i686-linux" "armv7l-linux" "aarch64-linux" ];
};
fetcher = vers: tag: hash: fetchurl {
url = "https://github.com/electron/electron/releases/download/v${vers}/electron-v${vers}-${tag}.zip";
sha256 = hash;
};
tags = {
i686-linux = "linux-ia32";
x86_64-linux = "linux-x64";
armv7l-linux = "linux-armv7l";
aarch64-linux = "linux-arm64";
x86_64-darwin = "darwin-x64";
};
get = as: platform: as.${platform.system} or
"Unsupported system: ${platform.system}";
common = platform: {
2019-08-09 18:45:58 +02:00
inherit name version meta;
src = fetcher version (get tags platform) (get hashes platform);
};
2019-08-09 18:45:58 +02:00
2020-05-21 19:41:22 +02:00
electronLibPath = stdenv.lib.makeLibraryPath ([ libuuid at-spi2-atk at-spi2-core ] ++ stdenv.lib.optionals (version > "9") [ libdrm mesa ]);
linux = {
2020-04-11 12:25:51 +02:00
buildInputs = [ glib gtk3 ];
2019-08-09 18:45:58 +02:00
nativeBuildInputs = [
unzip
makeWrapper
wrapGAppsHook
];
dontWrapGApps = true; # electron is in lib, we need to wrap it manually
2020-04-11 12:25:51 +02:00
dontUnpack = true;
dontBuild = true;
installPhase = ''
2019-08-09 18:45:58 +02:00
mkdir -p $out/lib/electron $out/bin
unzip -d $out/lib/electron $src
ln -s $out/lib/electron/electron $out/bin
2020-04-11 12:25:51 +02:00
'';
2019-08-09 18:45:58 +02:00
2020-04-11 12:25:51 +02:00
postFixup = ''
2019-08-09 18:45:58 +02:00
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
2020-05-21 19:41:22 +02:00
--set-rpath "${atomEnv.libPath}:${electronLibPath}:$out/lib/electron" \
2019-08-09 18:45:58 +02:00
$out/lib/electron/electron
wrapProgram $out/lib/electron/electron \
--prefix LD_PRELOAD : ${stdenv.lib.makeLibraryPath [ libXScrnSaver ]}/libXss.so.1 \
"''${gappsWrapperArgs[@]}"
'';
};
darwin = {
buildInputs = [ unzip ];
buildCommand = ''
mkdir -p $out/Applications
unzip $src
mv Electron.app $out/Applications
mkdir -p $out/bin
ln -s $out/Applications/Electron.app/Contents/MacOS/Electron $out/bin/electron
2019-08-09 18:45:58 +02:00
'';
};
in
stdenv.mkDerivation (
(common stdenv.hostPlatform) //
(if stdenv.isDarwin then darwin else linux)
)