summary refs log tree commit diff
path: root/pkgs/tools/networking/gnirehtet
diff options
context:
space:
mode:
authorSymphorien Gibol <symphorien+git@xlumurb.eu>2018-06-22 14:57:37 +0200
committerSymphorien Gibol <symphorien+git@xlumurb.eu>2018-06-22 19:21:23 +0200
commitf5307941ccc8936510afd8e1517049e190c0200a (patch)
tree1c00609007750317d0d674a35d5ecc694d7733a4 /pkgs/tools/networking/gnirehtet
parent75879177e839bf1c1d561419f15ff5551d927e37 (diff)
downloadnixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.tar
nixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.tar.gz
nixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.tar.bz2
nixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.tar.lz
nixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.tar.xz
nixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.tar.zst
nixpkgs-f5307941ccc8936510afd8e1517049e190c0200a.zip
gnirehtet: init at 2.2.1
Diffstat (limited to 'pkgs/tools/networking/gnirehtet')
-rw-r--r--pkgs/tools/networking/gnirehtet/default.nix50
-rw-r--r--pkgs/tools/networking/gnirehtet/paths.patch35
2 files changed, 85 insertions, 0 deletions
diff --git a/pkgs/tools/networking/gnirehtet/default.nix b/pkgs/tools/networking/gnirehtet/default.nix
new file mode 100644
index 00000000000..8a2d32e543b
--- /dev/null
+++ b/pkgs/tools/networking/gnirehtet/default.nix
@@ -0,0 +1,50 @@
+{stdenv, rustPlatform, fetchFromGitHub, fetchzip, androidenv, substituteAll}:
+let
+version = "2.2.1";
+apk = stdenv.mkDerivation {
+  name = "gnirehtet.apk-${version}";
+  src = fetchzip {
+    url = "https://github.com/Genymobile/gnirehtet/releases/download/v${version}/gnirehtet-rust-linux64-v${version}.zip";
+    sha256 = "1rz2wdjc1y7n8fhskmki1nj0ak80ylxspcsrcdnjkk9r7jbq0kan";
+  };
+  installPhase = ''
+    mkdir $out
+    mv gnirehtet.apk $out
+  '';
+};
+in
+rustPlatform.buildRustPackage rec {
+  name = "gnirehtet-${version}";
+
+  src = fetchFromGitHub {
+      owner = "Genymobile";
+      repo = "gnirehtet";
+      rev = "v${version}";
+      sha256 = "1mv8nq4422k2d766qjqqnqp47qzzbbvlwhdni0k6w4nmd3m5cnd9";
+  };
+  sourceRoot = "source/relay-rust";
+  cargoSha256 = "11qf9n6h6akvb0rbmsgdlfmypkbnas8ss1cs7i8w19mh7524n0v5";
+
+  patchFlags = [ "-p2" ];
+  patches = [
+    (substituteAll {
+      src = ./paths.patch;
+      adb = "${androidenv.platformTools}/bin/adb";
+      inherit apk;
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    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.
+    '';
+    homepage = https://github.com/Genymobile/gnirehtet;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ symphorien ];
+    platforms = platforms.unix;
+  };
+}
+
diff --git a/pkgs/tools/networking/gnirehtet/paths.patch b/pkgs/tools/networking/gnirehtet/paths.patch
new file mode 100644
index 00000000000..72a8445d83b
--- /dev/null
+++ b/pkgs/tools/networking/gnirehtet/paths.patch
@@ -0,0 +1,35 @@
+diff --git a/relay-rust/src/main.rs b/relay-rust/src/main.rs
+index 4f1be53..96d2e78 100644
+--- a/relay-rust/src/main.rs
++++ b/relay-rust/src/main.rs
+@@ -299,7 +299,7 @@ impl Command for RelayCommand {
+ 
+ fn cmd_install(serial: Option<&String>) -> Result<(), CommandExecutionError> {
+     info!(target: TAG, "Installing gnirehtet client...");
+-    exec_adb(serial, vec!["install", "-r", "gnirehtet.apk"])
++    exec_adb(serial, vec!["install", "-r", "@apk@/gnirehtet.apk"])
+ }
+ 
+ fn cmd_uninstall(serial: Option<&String>) -> Result<(), CommandExecutionError> {
+@@ -467,8 +467,8 @@ fn exec_adb<S: Into<String>>(
+     args: Vec<S>,
+ ) -> Result<(), CommandExecutionError> {
+     let adb_args = create_adb_args(serial, args);
+-    debug!(target: TAG, "Execute: adb {:?}", adb_args);
+-    match process::Command::new("adb").args(&adb_args[..]).status() {
++    debug!(target: TAG, "Execute: @adb@ {:?}", adb_args);
++    match process::Command::new("@adb@").args(&adb_args[..]).status() {
+         Ok(exit_status) => {
+             if exit_status.success() {
+                 Ok(())
+@@ -490,8 +490,8 @@ fn must_install_client(serial: Option<&String>) -> Result<bool, CommandExecution
+         serial,
+         vec!["shell", "dumpsys", "package", "com.genymobile.gnirehtet"],
+     );
+-    debug!(target: TAG, "Execute: adb {:?}", args);
+-    match process::Command::new("adb").args(&args[..]).output() {
++    debug!(target: TAG, "Execute: @adb@ {:?}", args);
++    match process::Command::new("@adb@").args(&args[..]).output() {
+         Ok(output) => {
+             if output.status.success() {
+                 // the "regex" crate makes the binary far bigger, so just parse the versionCode