nixpkgs/pkgs/development/tools/electron/default.nix

87 lines
2.9 KiB
Nix
Raw Normal View History

{ stdenv, libXScrnSaver, makeWrapper, fetchurl, wrapGAppsHook, gtk3, unzip, atomEnv, libuuid, at-spi2-atk }:
2016-04-04 17:11:41 +01:00
let
2019-08-04 07:57:33 +01:00
version = "4.2.8";
name = "electron-${version}";
2014-11-13 05:39:58 +00:00
throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
meta = with stdenv.lib; {
description = "Cross platform desktop application shell";
homepage = https://github.com/electron/electron;
license = licenses.mit;
2018-02-22 20:03:08 +00:00
maintainers = with maintainers; [ travisbhartwell manveru ];
platforms = [ "x86_64-darwin" "x86_64-linux" "i686-linux" "armv7l-linux" "aarch64-linux" ];
2014-11-13 05:39:58 +00:00
};
linux = {
inherit name version meta;
src = {
i686-linux = fetchurl {
url = "https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-linux-ia32.zip";
2019-08-04 07:57:33 +01:00
sha256 = "1sikxr0pfpi3wrf1d7fia1vhb1gacsy9pr7qc0fycgnzsy2nvf8n";
};
x86_64-linux = fetchurl {
url = "https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-linux-x64.zip";
2019-08-04 07:57:33 +01:00
sha256 = "0wc954cjc13flvdh8rkmnifdx6nirf273v1n76lsklbsq6c73i4h";
};
armv7l-linux = fetchurl {
url = "https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-linux-armv7l.zip";
2019-08-04 07:57:33 +01:00
sha256 = "0370ygpsm42drm70gj12i6mg960wchhqis7zz8i9is2ax1b2xjp5";
2018-02-22 20:03:08 +00:00
};
aarch64-linux = fetchurl {
url = "https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-linux-arm64.zip";
2019-08-04 07:57:33 +01:00
sha256 = "0vl90lsjcsgcxivbaq526ffbx3lsh6axfmpkfxl8cj2jlbsg593k";
};
}.${stdenv.hostPlatform.system} or throwSystem;
2014-11-13 05:39:58 +00:00
buildInputs = [ gtk3 ];
nativeBuildInputs = [
unzip
makeWrapper
wrapGAppsHook
];
dontWrapGApps = true; # electron is in lib, we need to wrap it manually
buildCommand = ''
mkdir -p $out/lib/electron $out/bin
unzip -d $out/lib/electron $src
ln -s $out/lib/electron/electron $out/bin
2016-06-08 19:31:36 +01:00
fixupPhase
2014-11-13 05:39:58 +00:00
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
2018-12-24 15:56:28 +00:00
--set-rpath "${atomEnv.libPath}:${stdenv.lib.makeLibraryPath [ libuuid at-spi2-atk ]}:$out/lib/electron" \
$out/lib/electron/electron
wrapProgram $out/lib/electron/electron \
--prefix LD_PRELOAD : ${stdenv.lib.makeLibraryPath [ libXScrnSaver ]}/libXss.so.1 \
"''${gappsWrapperArgs[@]}"
'';
2014-11-13 05:39:58 +00:00
};
darwin = {
inherit name version meta;
src = fetchurl {
url = "https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-darwin-x64.zip";
2019-08-04 07:57:33 +01:00
sha256 = "083v8k17b596fa63a7qrwyn2k8pd5vmg9yijbqbnpfcg4ja3bjx9";
};
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
'';
};
in
stdenv.mkDerivation (if stdenv.isDarwin then darwin else linux)