Skip to content

Instantly share code, notes, and snippets.

@inscapist
Created May 28, 2024 16:01
Show Gist options
  • Save inscapist/70ea328b59d17b234c14e14b505f81b2 to your computer and use it in GitHub Desktop.
Save inscapist/70ea328b59d17b234c14e14b505f81b2 to your computer and use it in GitHub Desktop.
Flutter nix flake for android
{
description = "Flutter on NixOS.";
inputs = {
# We disable this to use indirect nixpkgs from android-nixpkgs
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
android-nixpkgs.url = "github:tadfisher/android-nixpkgs";
};
outputs =
{
flake-utils,
nixpkgs,
android-nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config = {
android_sdk.accept_license = true;
allowUnfree = true;
};
};
pinnedJDK = pkgs.jdk17;
sdk = android-nixpkgs.sdk.${system} (
sdkPkgs: with sdkPkgs; [
build-tools-30-0-3
build-tools-33-0-2
build-tools-34-0-0
platforms-android-30
platforms-android-31
platforms-android-34
cmdline-tools-latest
platform-tools
# emulator
]
);
in
{
devShell = pkgs.mkShell {
JAVA_HOME = pinnedJDK.home;
ANDROID_HOME = "${sdk}/share/android-sdk";
# Fix an issue with Flutter using an older version of aapt2, which does not know
# an used parameter.
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${sdk}/share/android-sdk/build-tools/34.0.0/aapt2";
# CHROME_EXECUTABLE = "${pkgs.brave}/bin/brave";
buildInputs = with pkgs; [
pinnedJDK
sdk
flutter
# pkgs.androidStudioPackages.stable
# android-studio
];
};
}
);
}
@inscapist
Copy link
Author

sudo adb start-server
sudo adb reconnect

adb devices
flutter doctor -v

@inscapist
Copy link
Author

inscapist commented May 28, 2024

"USB preferences" in developer settings set to "File transfer(MTP)" or "PTP". Otherwise we might get "Insufficient permissions for device.."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment