2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2019-03-19 21:40:29 +00:00
|
|
|
, fetchurl
|
|
|
|
, gcc-unwrapped
|
|
|
|
, dpkg
|
2020-11-24 15:29:28 +00:00
|
|
|
, util-linux
|
2019-03-19 21:40:29 +00:00
|
|
|
, bash
|
2020-04-27 21:22:56 +01:00
|
|
|
, makeWrapper
|
2021-12-01 18:58:22 +00:00
|
|
|
, electron
|
2019-03-19 21:40:29 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-10-29 15:10:03 +01:00
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
|
|
|
|
throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
|
|
|
|
|
2019-03-19 21:40:29 +00:00
|
|
|
sha256 = {
|
2022-02-08 21:08:54 +00:00
|
|
|
"x86_64-linux" = "1yj6ybc99nqpzv2wjmvi7khfb5viwlb2rbjdpvgr4pmlzmiv7n2k";
|
|
|
|
"i686-linux" = "09ddcqxw1jhl8v461ngdgj2l4infn2xiwvaqxi6qp3swci627vmz";
|
2021-10-29 15:10:03 +01:00
|
|
|
}."${system}" or throwSystem;
|
2019-03-19 21:40:29 +00:00
|
|
|
|
|
|
|
arch = {
|
|
|
|
"x86_64-linux" = "amd64";
|
|
|
|
"i686-linux" = "i386";
|
2021-10-29 15:10:03 +01:00
|
|
|
}."${system}" or throwSystem;
|
2019-03-19 21:40:29 +00:00
|
|
|
|
2020-04-27 21:22:56 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-03-19 21:40:29 +00:00
|
|
|
pname = "etcher";
|
2022-02-08 21:08:54 +00:00
|
|
|
version = "1.7.3";
|
2019-03-19 21:40:29 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/balena-io/etcher/releases/download/v${version}/balena-etcher-electron_${version}_${arch}.deb";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2020-04-27 21:22:56 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
2021-04-23 13:21:35 +01:00
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
2019-03-19 21:40:29 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
${dpkg}/bin/dpkg-deb -x $src .
|
|
|
|
'';
|
|
|
|
|
|
|
|
# sudo-prompt has hardcoded binary paths on Linux and we patch them here
|
|
|
|
# along with some other paths
|
2021-04-23 13:21:35 +01:00
|
|
|
postPatch = ''
|
2020-04-27 21:22:56 +01:00
|
|
|
# use Nix(OS) paths
|
2021-04-23 13:21:35 +01:00
|
|
|
substituteInPlace opt/balenaEtcher/resources/app/generated/gui.js \
|
|
|
|
--replace '/usr/bin/pkexec' '/usr/bin/pkexec", "/run/wrappers/bin/pkexec' \
|
|
|
|
--replace '/bin/bash' '${bash}/bin/bash' \
|
|
|
|
--replace '"lsblk"' '"${util-linux}/bin/lsblk"'
|
2019-03-19 21:40:29 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2020-04-27 21:22:56 +01:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin $out/share/${pname}
|
|
|
|
|
|
|
|
cp -a usr/share/* $out/share
|
|
|
|
cp -a opt/balenaEtcher/{locales,resources} $out/share/${pname}
|
2019-03-19 21:40:29 +00:00
|
|
|
|
2021-08-08 07:54:17 +01:00
|
|
|
substituteInPlace $out/share/applications/balena-etcher-electron.desktop \
|
|
|
|
--replace /opt/balenaEtcher/balena-etcher-electron ${pname}
|
|
|
|
|
2020-04-27 21:22:56 +01:00
|
|
|
runHook postInstall
|
2019-03-19 21:40:29 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-27 21:22:56 +01:00
|
|
|
postFixup = ''
|
2020-05-22 17:25:35 +01:00
|
|
|
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
|
2021-04-23 13:21:35 +01:00
|
|
|
--add-flags $out/share/${pname}/resources/app \
|
2021-01-15 09:19:50 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gcc-unwrapped.lib ]}"
|
2019-03-19 21:40:29 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-03-19 21:40:29 +00:00
|
|
|
description = "Flash OS images to SD cards and USB drives, safely and easily";
|
|
|
|
homepage = "https://etcher.io/";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.shou ];
|
|
|
|
platforms = [ "i686-linux" "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|