Created
April 16, 2024 05:00
-
-
Save shiryel/f738cfcf4fa90055ba498ab81a45b60a to your computer and use it in GitHub Desktop.
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 = "Android Emulator"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
flake-utils.url = "github:numtide/flake-utils/v1.0.0"; | |
}; | |
outputs = { self, nixpkgs, flake-utils }: | |
flake-utils.lib.eachDefaultSystem (system: | |
let | |
pkgs = import nixpkgs { | |
system = system; | |
config.android_sdk.accept_license = true; | |
config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ | |
"cmdline-tools" | |
"tools" | |
]; | |
}; | |
# options on: | |
# nixpkgs/pkgs/development/mobile/androidenv/compose-android-packages.nix | |
androidComposition = pkgs.androidenv.composeAndroidPackages { | |
cmdLineToolsVersion = "8.0"; | |
includeEmulator = true; | |
platformVersions = [ "30" ]; | |
includeNDK = true; | |
includeExtras = [ | |
"extras;google;gcm" | |
]; | |
extraLicenses = [ ]; | |
}; | |
androidsdk = androidComposition.androidsdk; | |
# FROM: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/compilers/flutter/flutter.nix | |
flutter_deps = pkgs: with pkgs; [ | |
bash | |
curl | |
dart | |
git | |
unzip | |
which | |
xz | |
# flutter test requires this lib | |
libGLU | |
# for android emulator | |
alsa-lib | |
dbus | |
expat | |
libpulseaudio | |
libuuid | |
xorg.libX11 | |
xorg.libxcb | |
xorg.libXcomposite | |
xorg.libXcursor | |
xorg.libXdamage | |
xorg.libXext | |
xorg.libXfixes | |
xorg.libXi | |
xorg.libXrender | |
xorg.libXtst | |
libGL | |
nspr | |
nss | |
systemd | |
]; | |
fhs = pkgs.buildFHSUserEnvBubblewrap { | |
name = "flutter-env"; | |
runScript = "zsh"; | |
multiPkgs = pkgs: with pkgs; [ | |
# Flutter only use these certificates | |
(runCommand "fedoracert" { } '' | |
mkdir -p $out/etc/pki/tls/ | |
ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs | |
'') | |
zlib | |
]; | |
targetPkgs = pkgs: with pkgs; [ | |
flutter.passthru.unwrapped | |
clang | |
# required on flutter doctor | |
cmake | |
ninja | |
pkg-config | |
glib | |
gtk3 # test with: pkg-config --libs gtk+-3.0 | |
# required on flutter run | |
xorg.xorgproto | |
libepoxy | |
] ++ (flutter_deps pkgs) ++ gtk3.propagatedBuildInputs ++ pango.propagatedBuildInputs; | |
profile = with pkgs; '' | |
export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} | |
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 | |
export JAVA_HOME="${jdk.home}"; | |
export ANDROID_JAVA_HOME="${jdk.home}"; | |
export ANDROID_HOME="${androidsdk}/libexec/android-sdk"; | |
export ANDROID_SDK_ROOT="${androidsdk}/libexec/android-sdk"; | |
''; | |
extraOutputsToInstall = [ "dev" ]; | |
}; | |
in | |
{ | |
devShell = fhs.env; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment