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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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