3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/misc/etcher/default.nix

84 lines
2.1 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-12-01 18:58:22 +00:00
, electron
}:
let
2021-10-29 15:10:03 +01:00
inherit (stdenv.hostPlatform) system;
throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
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;
arch = {
"x86_64-linux" = "amd64";
"i686-linux" = "i386";
2021-10-29 15:10:03 +01:00
}."${system}" or throwSystem;
2020-04-27 21:22:56 +01:00
in
stdenv.mkDerivation rec {
pname = "etcher";
2022-02-08 21:08:54 +00:00
version = "1.7.3";
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}
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
'';
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" ];
};
}