diff options
author | Benedict Aas <x+g@shou.io> | 2019-03-19 21:40:29 +0000 |
---|---|---|
committer | Lassulus <github@lassul.us> | 2019-12-08 15:46:58 +0100 |
commit | 24b8c6d7dc2235e9e10be1f6714242921b6b6967 (patch) | |
tree | 1c1a73c6afe3ca3b094db0923fbda9e52b460403 | |
parent | 975195a4743fabddb8410ef7a204501a70fc4bf5 (diff) |
etcher: init at 1.5.60
We add Etcher, the Electron image flasher.
-rw-r--r-- | pkgs/tools/misc/etcher/default.nix | 94 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
2 files changed, 96 insertions, 0 deletions
diff --git a/pkgs/tools/misc/etcher/default.nix b/pkgs/tools/misc/etcher/default.nix new file mode 100644 index 0000000000000..4944600108ae6 --- /dev/null +++ b/pkgs/tools/misc/etcher/default.nix @@ -0,0 +1,94 @@ +{ lib +, stdenv +, fetchurl +, gcc-unwrapped +, dpkg +, polkit +, bash +, nodePackages +, electron_3 +, gtk3 +, wrapGAppsHook +}: + +let + libPath = lib.makeLibraryPath [ + # for libstdc++.so.6 + gcc-unwrapped.lib + ]; + + sha256 = { + "x86_64-linux" = "0zb9j34dz7ybjix018bm8g0b6kilw9300q4ahcm22p0ggg528dh7"; + "i686-linux" = "0wsv4mvwrvsaz1pwiqs94b3854h5l8ff2dbb1ybxmvwjbfrkdcqc"; + }."${stdenv.system}"; + + arch = { + "x86_64-linux" = "amd64"; + "i686-linux" = "i386"; + }."${stdenv.system}"; + +in stdenv.mkDerivation rec { + pname = "etcher"; + version = "1.5.60"; + + src = fetchurl { + url = "https://github.com/balena-io/etcher/releases/download/v${version}/balena-etcher-electron_${version}_${arch}.deb"; + inherit sha256; + }; + + buildInputs = [ + gtk3 + ]; + + nativeBuildInputs = [ + wrapGAppsHook + ]; + + dontBuild = true; + dontConfigure = 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 + patchPhase = '' + ${nodePackages.asar}/bin/asar extract opt/balenaEtcher/resources/app.asar tmp + # Use Nix(OS) paths + sed -i "s|/usr/bin/pkexec|/usr/bin/pkexec', '/run/wrappers/bin/pkexec|" tmp/node_modules/sudo-prompt/index.js + sed -i 's|/bin/bash|${bash}/bin/bash|' tmp/node_modules/sudo-prompt/index.js + sed -i "s|process.resourcesPath|'$out/opt/balenaEtcher/resources/'|" tmp/generated/gui.js + ${nodePackages.asar}/bin/asar pack tmp opt/balenaEtcher/resources/app.asar + rm -rf tmp + # Fix up .desktop file + substituteInPlace usr/share/applications/balena-etcher-electron.desktop \ + --replace "/opt/balenaEtcher/balena-etcher-electron" "$out/bin/balena-etcher-electron" + ''; + + installPhase = '' + mkdir -p $out/bin + cp -r opt $out/ + cp -r usr/share $out/ + + # We'll use our Nixpkgs electron_3 instead + rm $out/opt/balenaEtcher/balena-etcher-electron + + ln -s ${electron_3}/bin/electron $out/bin/balena-etcher-electron + ''; + + preFixup = '' + gappsWrapperArgs+=( + --add-flags $out/opt/balenaEtcher/resources/app.asar + --prefix LD_LIBRARY_PATH : ${libPath} + ) + ''; + + meta = with stdenv.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" ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0db2fd476c463..c78d6626ef280 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3053,6 +3053,8 @@ in inherit (pythonPackages) buildPythonApplication pygtk numpy; }; + etcher = callPackage ../tools/misc/etcher { }; + ethtool = callPackage ../tools/misc/ethtool { }; ettercap = callPackage ../applications/networking/sniffers/ettercap { |