Created
May 28, 2024 16:01
-
-
Save inscapist/70ea328b59d17b234c14e14b505f81b2 to your computer and use it in GitHub Desktop.
Flutter nix flake for android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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 | |
]; | |
}; | |
} | |
); | |
} |
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