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

82 lines
2 KiB
Nix
Raw Normal View History

{ lib, stdenv
, fetchurl
, gcc-unwrapped
, dpkg
2020-11-24 16:29:28 +01:00
, util-linux
, bash
2020-04-27 22:22:56 +02:00
, makeWrapper
2021-04-23 14:21:35 +02:00
, electron_12
}:
let
sha256 = {
2021-09-06 08:16:05 +02:00
"x86_64-linux" = "sha256-Tasynkzyy8UIalQn6qhIuPWDflf4pL76D2czgEijrPw=";
2021-04-23 14:21:35 +02:00
"i686-linux" = "0z6y45sz086njpywg7f0jn6n02qynb1qbi889g2kcgwbfjvmcpm1";
}."${stdenv.system}";
arch = {
"x86_64-linux" = "amd64";
"i686-linux" = "i386";
}."${stdenv.system}";
2021-04-23 14:21:35 +02:00
electron = electron_12;
2020-04-27 22:22:56 +02:00
in
stdenv.mkDerivation rec {
pname = "etcher";
2021-09-06 08:16:05 +02:00
version = "1.5.122";
src = fetchurl {
url = "https://github.com/balena-io/etcher/releases/download/v${version}/balena-etcher-electron_${version}_${arch}.deb";
inherit sha256;
};
2020-04-27 22:22:56 +02:00
nativeBuildInputs = [ makeWrapper ];
2021-04-23 14:21:35 +02: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 14:21:35 +02:00
postPatch = ''
2020-04-27 22:22:56 +02:00
# use Nix(OS) paths
2021-04-23 14:21:35 +02: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 22:22:56 +02: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}
2021-08-08 08:54:17 +02:00
substituteInPlace $out/share/applications/balena-etcher-electron.desktop \
--replace /opt/balenaEtcher/balena-etcher-electron ${pname}
2020-04-27 22:22:56 +02:00
runHook postInstall
'';
2020-04-27 22:22:56 +02:00
postFixup = ''
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
2021-04-23 14:21:35 +02:00
--add-flags $out/share/${pname}/resources/app \
2021-01-15 10:19:50 +01: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" ];
};
}