nixpkgs/pkgs/tools/misc/etcher/default.nix

79 lines
1.9 KiB
Nix
Raw Normal View History

{ lib, stdenv
, fetchurl
, gcc-unwrapped
, dpkg
2020-11-24 15:29:28 +00:00
, util-linux
, bash
2020-04-27 21:22:56 +01:00
, makeWrapper
2021-04-23 13:21:35 +01:00
, electron_12
}:
let
sha256 = {
2021-07-20 03:42:49 +01:00
"x86_64-linux" = "sha256-FRZTUOlOK1bIbrHdR9yQv45zMhby3tWbMPpaPPq3L9s=";
2021-04-23 13:21:35 +01:00
"i686-linux" = "0z6y45sz086njpywg7f0jn6n02qynb1qbi889g2kcgwbfjvmcpm1";
}."${stdenv.system}";
arch = {
"x86_64-linux" = "amd64";
"i686-linux" = "i386";
}."${stdenv.system}";
2021-04-23 13:21:35 +01:00
electron = electron_12;
2020-04-27 21:22:56 +01:00
in
stdenv.mkDerivation rec {
pname = "etcher";
2021-07-20 03:42:49 +01:00
version = "1.5.121";
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;
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"'
'';
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}
2020-04-27 21:22:56 +01:00
runHook postInstall
'';
2020-04-27 21:22:56 +01:00
postFixup = ''
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 ]}"
'';
meta = with lib; {
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" ];
};
}