diff --git a/README.md b/README.md index a0e344d..fd96961 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This repository contains the open source Tailscale Android client. SDK](https://developer.android.com/studio/releases/platform-tools), the [Android NDK](https://developer.android.com/ndk) are required. -``` +```sh $ make tailscale-debug.apk $ adb install -r tailscale-debug.apk ``` @@ -31,11 +31,19 @@ $ adb install -r tailscale-debug.apk The `dockershell` target builds a container with the necessary dependencies and runs a shell inside it. -``` +```sh $ make dockershell # make tailscale-debug.apk ``` +If you have Nix 2.4 or later installed, a Nix development environment can +be set up with + +```sh +$ alias nix='nix --extra-experimental-features "nix-command flakes"' +$ nix develop +``` + Use `make tag_release` to bump the Android version code, update the version name, and tag the current commit. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9f85985 --- /dev/null +++ b/flake.lock @@ -0,0 +1,114 @@ +{ + "nodes": { + "android": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1648412532, + "narHash": "sha256-zh0rLcppJ5i2Bh8oBWjBhDvgOrMhDGdXINbp3bhrs0U=", + "owner": "tadfisher", + "repo": "android-nixpkgs", + "rev": "b1318b23926260685dbb09dd127f38c917fc7441", + "type": "github" + }, + "original": { + "owner": "tadfisher", + "repo": "android-nixpkgs", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1647857022, + "narHash": "sha256-Aw70NWLOIwKhT60MHDGjgWis3DP3faCzr6ap9CSayek=", + "owner": "numtide", + "repo": "devshell", + "rev": "0a5ff74dacb9ea22614f64e61aeb3ca0bf0e7311", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1648297722, + "narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1643381941, + "narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1648484058, + "narHash": "sha256-YJFeh59/HMassannh6JJuy+0l305xFhvUPxWLITRgWk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e4b25c3f0a8828e39e6194c3f7b142a937a9d51f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "android": "android", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..92c0496 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Tailscale build environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + android.url = "github:tadfisher/android-nixpkgs"; + android.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, android }: + let + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); + in + { + devShells = forAllSystems + (system: + let + pkgs = import nixpkgs { + inherit system; + }; + android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; + [ + build-tools-30-0-2 + cmdline-tools-latest + platform-tools + platforms-android-31 + platforms-android-30 + ndk-23-1-7779620 + patcher-v4 + ]); + in + { + default = (with pkgs; buildFHSUserEnv { + name = "tailscale"; + profile = '' + export ANDROID_SDK_ROOT="${android-sdk}/share/android-sdk" + export JAVA_HOME="${jdk8.home}" + ''; + targetPkgs = pkgs: with pkgs; [ + android-sdk + jdk8 + clang + ] ++ (if stdenv.isLinux then [ + vulkan-headers + libxkbcommon + wayland + xorg.libX11 + xorg.libXcursor + xorg.libXfixes + libGL + pkgconfig + ] else [ ]); + }).env; + } + ); + }; +}