2022-12-27 18:39:19 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, fetchzip
|
|
|
|
, androidenv
|
|
|
|
, makeWrapper
|
|
|
|
}:
|
2018-06-22 14:57:37 +02:00
|
|
|
let
|
2020-08-29 14:00:00 +02:00
|
|
|
version = "2.5";
|
2018-06-22 14:57:37 +02:00
|
|
|
apk = stdenv.mkDerivation {
|
2019-08-13 23:52:01 +02:00
|
|
|
pname = "gnirehtet.apk";
|
|
|
|
inherit version;
|
2018-06-22 14:57:37 +02:00
|
|
|
src = fetchzip {
|
|
|
|
url = "https://github.com/Genymobile/gnirehtet/releases/download/v${version}/gnirehtet-rust-linux64-v${version}.zip";
|
2022-12-27 18:39:19 +01:00
|
|
|
hash = "sha256-+H35OoTFILnJudW6+hOaLDMVZcraYT8hfJGiX958YLU=";
|
2018-06-22 14:57:37 +02:00
|
|
|
};
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
mv gnirehtet.apk $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2019-08-13 23:52:01 +02:00
|
|
|
rustPlatform.buildRustPackage {
|
2019-08-31 13:41:23 +02:00
|
|
|
pname = "gnirehtet";
|
|
|
|
inherit version;
|
2018-06-22 14:57:37 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-12-27 18:39:19 +01:00
|
|
|
owner = "Genymobile";
|
|
|
|
repo = "gnirehtet";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-6KBHRgFvHLqPXkMo1ij0D0ERQICCFGvI7EnaJxCwZnI=";
|
2018-06-22 14:57:37 +02:00
|
|
|
};
|
2022-12-27 18:39:19 +01:00
|
|
|
|
2018-06-22 14:57:37 +02:00
|
|
|
sourceRoot = "source/relay-rust";
|
2022-12-27 18:39:19 +01:00
|
|
|
|
|
|
|
cargoPatches = [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-trailing-semicolon-in-macro.patch";
|
|
|
|
url = "https://github.com/Genymobile/gnirehtet/commit/537b3d87344a456e1310f10dcef37592063f4e54.patch";
|
|
|
|
hash = "sha256-6U4ZEcqyXcXrfLRtynepS7gp+Uh5sujRyHVLXbWvpq8=";
|
|
|
|
stripLen = 1;
|
|
|
|
})
|
|
|
|
# Updates Cargo.lock and is needed to apply the subsequent patch
|
|
|
|
(fetchpatch {
|
|
|
|
name = "prefix-unused-field-with-underscore.patch";
|
|
|
|
url = "https://github.com/Genymobile/gnirehtet/commit/2f695503dd80519ce73a80c5aa360b08a97c029d.patch";
|
|
|
|
hash = "sha256-YVd1B2PVLRGpJNkKb7gpUQWmccfvYaeAmayOmWg8D+Y=";
|
|
|
|
stripLen = 1;
|
|
|
|
})
|
|
|
|
# https://github.com/Genymobile/gnirehtet/pull/478
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-for-rust-1.64.patch";
|
|
|
|
url = "https://github.com/Genymobile/gnirehtet/commit/8eeed2084d0d1e2f83056bd11622beaa1fa61281.patch";
|
|
|
|
hash = "sha256-Wwc+4vG48/qpusGjlE+mSJvvarYq2mQ2CkDkrtKHAwo=";
|
|
|
|
stripLen = 1;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
cargoHash = "sha256-3iYOeHIQHwxmh8b8vKUf5fQS2fXP2g3orLquvLXzZwE=";
|
2018-06-22 14:57:37 +02:00
|
|
|
|
2020-08-29 14:00:00 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
wrapProgram $out/bin/gnirehtet \
|
|
|
|
--set GNIREHTET_APK ${apk}/gnirehtet.apk \
|
|
|
|
--set ADB ${androidenv.androidPkgs_9_0.platform-tools}/bin/adb
|
|
|
|
'';
|
2018-06-22 14:57:37 +02:00
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2018-06-22 14:57:37 +02:00
|
|
|
description = "Reverse tethering over adb for Android";
|
|
|
|
longDescription = ''
|
|
|
|
This project provides reverse tethering over adb for Android: it allows devices to use the internet connection of the computer they are plugged on. It does not require any root access (neither on the device nor on the computer).
|
|
|
|
|
|
|
|
This relies on adb, make sure you have the required permissions/udev rules.
|
|
|
|
'';
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://github.com/Genymobile/gnirehtet";
|
2022-06-11 13:39:53 +02:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
fromSource
|
|
|
|
binaryBytecode # gnirehtet.apk
|
|
|
|
];
|
2018-06-22 14:57:37 +02:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ symphorien ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|