Skip to content

Commit

Permalink
add nix (#1213)
Browse files Browse the repository at this point in the history
* add flake

* consolidate into flake.nix

* fix build
  • Loading branch information
allen-branch authored Aug 19, 2024
1 parent f96b38a commit 3e95a0f
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 2 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ Branch-SDK-TestBed/gradlew
Branch-SDK-TestBed/gradlew.bat

Branch-SDK-TestBed/gradle/wrapper/gradle-wrapper.properties

.direnv
3 changes: 2 additions & 1 deletion Branch-SDK/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dependencies {
}

val VERSION_NAME: String by project
val ANDROID_BUILD_TOOLS_VERSION: String by project
val ANDROID_BUILD_SDK_VERSION_COMPILE: String by project
val ANDROID_BUILD_SDK_VERSION_MINIMUM: String by project
val VERSION_CODE: String by project
Expand All @@ -72,7 +73,7 @@ fun isReleaseBuild(): Boolean {

android {
compileSdk = ANDROID_BUILD_SDK_VERSION_COMPILE.toInt()

buildToolsVersion = ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdk = ANDROID_BUILD_SDK_VERSION_MINIMUM.toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
185 changes: 185 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
description = "Branch Android SDK for deep linking and attribution";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
android.url = "github:tadfisher/android-nixpkgs";
};

outputs = { self, nixpkgs, flake-utils, android }: flake-utils.lib.eachSystem [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ] (system:
let
inherit (nixpkgs) lib;
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
(final: prev: {
android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; [
build-tools-34-0-0
cmdline-tools-latest
emulator
platform-tools
platforms-android-34
]
++ lib.optionals (system == "aarch64-darwin") [
system-images-android-34-google-apis-arm64-v8a
]
++ lib.optionals (system == "x86_64-darwin" || system == "x86_64-linux") [
system-images-android-34-google-apis-x86-64
]);
})
];
};
in
{
formatter = pkgs.nixpkgs-fmt;
devShells = {
default = pkgs.mkShell {
name = "branch-sdk-android";
ANDROID_HOME = "${pkgs.android-sdk}/share/android-sdk";
ANDROID_SDK_ROOT = "${pkgs.android-sdk}/share/android-sdk";
JAVA_HOME = "${pkgs.jdk17.home}";
shellHook = ''
echo "
Entered the Branch SDK Android development environment.
";
'';
packages = [
pkgs.android-sdk
pkgs.jdk17 # for android build-tools
];
};
};
}
);
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=branch
POM_DEVELOPER_NAME=Branch Metrics

ANDROID_BUILD_SDK_VERSION_MINIMUM=21
ANDROID_BUILD_SDK_VERSION_MINIMUM=23
ANDROID_BUILD_SDK_VERSION_COMPILE=34
ANDROID_BUILD_TOOLS_VERSION=34.0.0
android.useAndroidX=true

0 comments on commit 3e95a0f

Please sign in to comment.