Merge pull request #120334 from LumiGuide/upd-balena

This commit is contained in:
Sandro 2021-05-11 11:02:30 +02:00 committed by GitHub
commit 5f86a5de27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,18 +2,16 @@
, fetchurl , fetchurl
, gcc-unwrapped , gcc-unwrapped
, dpkg , dpkg
, polkit
, util-linux , util-linux
, bash , bash
, nodePackages
, makeWrapper , makeWrapper
, electron_7 , electron_12
}: }:
let let
sha256 = { sha256 = {
"x86_64-linux" = "1yvqi86bw0kym401zwknhwq9041fxg047sbj3aydnfcqf11vrrmk"; "x86_64-linux" = "03nxcafg405vcs4sb5qhpm5aqaai87d9ksqkl37mmzf6g0n4qbih";
"i686-linux" = "12lghzhsl16h3jvzm3vw4hrly32fz99z6rdmybl8viralrxy8mb8"; "i686-linux" = "0z6y45sz086njpywg7f0jn6n02qynb1qbi889g2kcgwbfjvmcpm1";
}."${stdenv.system}"; }."${stdenv.system}";
arch = { arch = {
@ -21,39 +19,36 @@ let
"i686-linux" = "i386"; "i686-linux" = "i386";
}."${stdenv.system}"; }."${stdenv.system}";
electron = electron_7; electron = electron_12;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "etcher"; pname = "etcher";
version = "1.5.86"; version = "1.5.117";
src = fetchurl { src = fetchurl {
url = "https://github.com/balena-io/etcher/releases/download/v${version}/balena-etcher-electron_${version}_${arch}.deb"; url = "https://github.com/balena-io/etcher/releases/download/v${version}/balena-etcher-electron_${version}_${arch}.deb";
inherit sha256; inherit sha256;
}; };
dontBuild = true;
dontConfigure = true;
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
dontConfigure = true;
dontBuild = true;
unpackPhase = '' unpackPhase = ''
${dpkg}/bin/dpkg-deb -x $src . ${dpkg}/bin/dpkg-deb -x $src .
''; '';
# sudo-prompt has hardcoded binary paths on Linux and we patch them here # sudo-prompt has hardcoded binary paths on Linux and we patch them here
# along with some other paths # along with some other paths
patchPhase = '' postPatch = ''
${nodePackages.asar}/bin/asar extract opt/balenaEtcher/resources/app.asar tmp
# use Nix(OS) paths # use Nix(OS) paths
sed -i "s|/usr/bin/pkexec|/usr/bin/pkexec', '/run/wrappers/bin/pkexec|" tmp/node_modules/sudo-prompt/index.js substituteInPlace opt/balenaEtcher/resources/app/generated/gui.js \
sed -i 's|/bin/bash|${bash}/bin/bash|' tmp/node_modules/sudo-prompt/index.js --replace '/usr/bin/pkexec' '/usr/bin/pkexec", "/run/wrappers/bin/pkexec' \
sed -i "s|'lsblk'|'${util-linux}/bin/lsblk'|" tmp/node_modules/drivelist/js/lsblk/index.js --replace '/bin/bash' '${bash}/bin/bash' \
sed -i "s|process.resourcesPath|'$out/share/${pname}/resources/'|" tmp/generated/gui.js --replace '"lsblk"' '"${util-linux}/bin/lsblk"'
${nodePackages.asar}/bin/asar pack tmp opt/balenaEtcher/resources/app.asar
rm -rf tmp
''; '';
installPhase = '' installPhase = ''
@ -64,15 +59,12 @@ stdenv.mkDerivation rec {
cp -a usr/share/* $out/share cp -a usr/share/* $out/share
cp -a opt/balenaEtcher/{locales,resources} $out/share/${pname} cp -a opt/balenaEtcher/{locales,resources} $out/share/${pname}
substituteInPlace $out/share/applications/balena-etcher-electron.desktop \
--replace 'Exec=/opt/balenaEtcher/balena-etcher-electron' 'Exec=${pname}'
runHook postInstall runHook postInstall
''; '';
postFixup = '' postFixup = ''
makeWrapper ${electron}/bin/electron $out/bin/${pname} \ makeWrapper ${electron}/bin/electron $out/bin/${pname} \
--add-flags $out/share/${pname}/resources/app.asar \ --add-flags $out/share/${pname}/resources/app \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gcc-unwrapped.lib ]}" --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gcc-unwrapped.lib ]}"
''; '';