feat: add an android flake

This commit is contained in:
Artur Manuel 2024-12-04 15:44:04 +00:00
commit 1c8f6a7606
2 changed files with 261 additions and 0 deletions

View file

@ -0,0 +1,78 @@
{
description = "My Android project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts";
android.url = "github:tadfisher/android-nixpkgs";
};
outputs = inputs @ {
self,
nixpkgs,
...
}:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"];
imports = [
inputs.devshell.flakeModule
];
flake = {
overlays.default = final: prev: {
android-sdk = inputs.android.sdk.${final.system} (sdkPkgs:
builtins.attrValues {
inherit
(sdkPkgs)
build-tools-34-0-0
cmdline-tools-latest
emulator
platform-tools
platforms-android-34
;
});
android-studio = prev.androidStudioPackages.stable;
};
};
perSystem = {
pkgs,
system,
self',
}: {
_module.args.pkgs = import nixpkgs {
config.allowUnfree = true;
inherit system;
overlays = [
inputs.devshell.overlays.default
self.overlays.default
];
};
packages = {inherit (pkgs) android-studio android-sdk;};
devshells.default = {
env = [
{
name = "ANDROID_HOME";
value = "${self'.packages.android-sdk}/share/android-sdk";
}
{
name = "ANDROID_SDK_ROOT";
value = "${self'.packages.android-sdk}/share/android-sdk";
}
{
name = "JAVA_HOME";
value = pkgs.jdk.home;
}
];
packages = builtins.attrValues {
inherit
(pkgs)
android-sdk
gradle
jdk
android-studio
;
};
};
};
};
}