38 Commits

Author SHA1 Message Date
Morgan Jones
9c2f0302bf androidenv: ANDROID_SDK_ROOT -> ANDROID_HOME
Change the 'primary' env var to ANDROID_HOME.
Always export ANDROID_SDK_ROOT for compatibility.
2026-04-19 17:32:01 -07:00
Morgan Jones
a1241180d7 androidenv: fix new "37.0" packages with API version ranges
Google has seemed to require this suffix on their newer packages,
and also doesn't provide sources anymore. Fix both issues.
2026-04-05 18:37:23 -07:00
Morgan Jones
03d6e4bc46 androidenv: support nonstandard SDK versions
Google have been releasing 'nonstandard' SDK versions for a while. Named
things like CANARY, UpsideDownCake, 36x, and so on, androidenv has been
generally unable to use them, instead preferring Google's officially
supported Android SDKs corresponding to the
[API levels](https://apilevels.com/) (e.g. "35" or "36").

Updates to those SDK versions have generally come in the form of
updates to Google's repositories that repo.json picks up.
These are mostly noneventful for end users, unless a user experienced a
bug in an API definition, then it tended to be picked up with an
androidenv repo update.

API 36.1 changes this. It's not just a number (so it doesn't correspond
to a unique API level). The previous attempt in #470569 simply preferred
the newer version to attempt to emulate the old behavior.

Unfortunately, this now requires a Gradle change (see #472561). So this
means we should just support all the strange SDK versions now and have a
test for it.

Note that only depending on "latest" (the default) will properly pick
these up as the latest, but using a min and max SDK version or
numLatestPlatformVersions > 1 will create a range of SDK versions as
before, which means you may miss (e.g.) 36.1 but will still have 36.
Considering that this requires `compileSdk "android-36.1"`
instead of a simple `compileSdk 36` in Gradle, it's recommended to
explicitly specify platformVersions if you depend on this change,
or use the defaults, where it will only install the latest.
2025-12-22 23:45:00 -08:00
Morgan Jones
dcac273d94 androidenv: fix 'latest' where SDK level is not an int
Map 'latest' to the latest minor version of each SDK level, since Google
now has minor versions of SDK levels. The SDK levels are still integers,
so also map "36" to (e.g.) "36.1" by default, since the user likely
wants the latest revision of "36" we have.

Fix: #468525
2025-12-13 16:23:47 -08:00
NAHO
c8d4dabc43 pkgs: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --type file \
      . \
      pkgs \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2025-10-04 19:02:37 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Morgan Jones
8bd119929d androidenv: fix autoupdate and custom XMLs
This regression happened during refactoring of mkrepo.rb. Do another
round of it with a focus on fixing the autoupdate and use of custom
repository XMLs.

Add an example to check this behavior (but don't run it in the test
suite, since it requires IFD).
2025-05-29 01:00:19 -07:00
Morgan Jones
f97ca76b10 androidenv: support linking "latest" version of all plugins
As noted in #379534, the NDK linking broke during refactoring. Add a test
for that, and support linking the latest for all platform plugins that
take at least one version.
2025-04-27 17:55:02 -07:00
Morgan Jones
6281e51213 androidenv: fix missing versions for Google addons
This is a regression caused by fixing the linking of Google TV addons.
Change the check so we just check for the package being present instead
of checking the specific version.
2025-04-13 23:22:03 +05:30
Morgan Jones
81ac8a7666 androidenv: support 5 years of Android APIs with images; test 10 without
Cut down on the number of system images that need to be fetched by just
supporting packages from the last 5 years. Still test the last 10 years
of APIs without images.
2025-03-29 22:13:03 +05:30
Morgan Jones
b757ce39d6 androidenv: support minPlatformVersion and maxPlatformVersion
With the release of Android API 36, it was getting rather annoying to
need to keep these updated. Allow just specifying the min and max
instead.
2025-03-29 22:13:03 +05:30
Morgan Jones
807356fa69 androidenv: accept license during tests 2025-03-29 22:13:03 +05:30
Morgan Jones
3c13841124 androidenv: nixfmt 2025-03-29 22:13:03 +05:30
Morgan Jones
803aebe826 androidenv: support if-supported for include* options
This lets us stop hardcoding platforms and start filtering for which
archives have sources, which is the most accurate way to do it.

Tested on x86_64-linux, aarch64-linux, and aarch64-darwin.
2025-03-29 22:13:03 +05:30
Morgan Jones
fb25c379f4 androidenv: simplify updating and track latest
We can figure out the latest version for every package in mkrepo.rb,
instead of repeating ourselves in compose-android-packages.

Track the latest non-preview versions of all packages by default, and
remove version hardcoding everywhere. Enable the update script.
2025-03-29 22:13:03 +05:30
Sigmanificient
91d5ab3ae4 treewide: remove unused rec expressions 2025-03-14 05:15:05 +01:00
Hadi
d3f8c4d495 androidenv: upgradde to repository2-3
androidenv: apply numinit patch to have a nice error message

androidenv handle unsupported systems, and make tests running by default!

androidenv run nixfmt

androidenv: support emulator/systemimages/NDK only for certain systems

androidenv: apply nixfmt

androidenv: give a warning if archive doesn't exist
2025-02-20 11:33:43 +05:30
Hadi
1ce07cfcbc androidenv fix extras;google;auto
fix SDL_CreateWindowRenderer's problem while initiating the desktop-head-unit

androidenv: format extras.nix

adding android-automotive-sys-img2-1.xml and ran mkrepo.sh which updated the packages

androidenv: apply nixfmt-rfc-style
2025-01-24 14:18:51 -05:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
Hadi
a551cfdc3e androidenv: updates for Android API 35 2024-08-20 15:42:13 -04:00
NAHO
a7cc1dcd68 treewide: fix broken 'nix.dev' URLs 2024-07-07 17:15:35 +02:00
Morgan Jones
a10fada751 androidenv: update to latest 2024-04-09 20:10:14 -07:00
Hadi
3f00b40fff androidenv: don't include emulator when includeEmulator is false 2024-01-22 19:04:40 -05:00
Hadi
da977da39e androidenv: fix bugs, add new arguments, and deprecate arguments
- Fix the bug in #265479
- New arguments:
  - configOptions
  - deviceName
- Deprecate arguments:
  - enableGPU
2023-12-15 16:20:39 -05:00
Morgan Jones
1809b32877 androidenv: updates for Android API 34 2023-11-05 14:31:44 +01:00
Hadi
430200fe06 androidenv update packages 2023-08-10 20:27:06 -04:00
Hadi
3310972785 androidenv: update repo.json with a new strategy to expire 2023-05-12 18:33:46 -04:00
Hadi
a05928d7fe androidenv: make nix-build -A androidenv.test-suite work
androidenv: set config.allowUnfree = true for integration tests

androidenv: fix concerns in the PR
2023-02-28 08:53:43 -05:00
Hadi
d511bfd0e2 androidenv: add shell-with-emulator.nix to have test and more examples
androidenv: replace buildInputs with nativeBuildInputs
2023-02-28 08:53:43 -05:00
Hadi
e5fbfd894f androidenv: fix problem with avdmanager when trying to create an avd
To do so, we gathered different system images with the same
abiVersion in the same derivation.
2023-02-28 08:53:43 -05:00
Hadi
9c4e43ab70 androidenv: Implement cmdline-tools and patcher
- Replace cmdline-tools with tools because tools is obsolete now.
- Depend emulator package to systemImages

androidenv: fix issues on the PR

androidenv: reformat

androidenv: support excluding of `tools` package

androidenv: provide `tools`, and `build-tools`, dependencies

androidenv: replace includeTools with toolsVersion

androidenv: fix a typo

androidenv: add tests to check licenses and installed packages

androidenv: check if tests are running! this commit should fail!

androidenv: fix problems in the review https://github.com/NixOS/nixpkgs/pull/208793

androidenv: add test-suite to handle more tests around

androidenv: fix the test after couldn't running them with ofborg

Update pkgs/development/mobile/androidenv/build-tools.nix

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

androidenv: Resolving https://github.com/NixOS/nixpkgs/pull/208793#discussion_r1065851539

Update pkgs/development/mobile/androidenv/cmdline-tools.nix

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

Update pkgs/development/mobile/androidenv/tools.nix

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

androidenv: fix a typo
2023-01-27 18:15:47 -05:00
Hadi
d1a1f2fa06 androidenv: Fix we are using 2 spaces to intend nix code in
see: https://github.com/NixOS/nixpkgs/pull/208137#discussion_r1059518929
2022-12-31 12:21:21 -05:00
Hadi
2f688374e0 androidenv: fix missing packages in repo json (#208137) 2022-12-30 15:28:12 +02:00
Artturin
a2f85e0fa8 androidenv: use callPackage instead of import & fix infinite recursion
infinite recursion was due to autoPatchelfHook being in buildInputs of
platform-tools, i will add a lint for it in nix-community/nixpkgs-lint.

```
$ nix build ".#pkgsCross.aarch64-android-prebuilt.hello" --show-trace 2>&1 | rg 'while evaluating the attr.+deriv'
    … while evaluating the attribute 'stdenv' of the derivation 'zlib-aarch64-unknown-linux-android-1.2.13'
    … while evaluating the attribute 'CPPFLAGS' of the derivation 'python3-aarch64-unknown-linux-android-3.10.8'
    … while evaluating the attribute 'setuptools' of the derivation 'python-catch-conflicts-hook'
    … while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.10-pyelftools-0.28'
    … while evaluating the attribute 'passAsFile' of the derivation 'python3-3.10.8-env'
    … while evaluating the attribute 'pythonInterpreter' of the derivation 'auto-patchelf-hook'
    … while evaluating the attribute 'buildInputs' of the derivation 'platform-tools-33.0.2'
    … while evaluating the attribute 'installPhase' of the derivation 'ndk-24.0.8215888'
    … while evaluating the attribute 'installPhase' of the derivation 'aarch64-unknown-linux-android-ndk-toolchain-24.0.8215888'
    … while evaluating the attribute 'bintools_bin' of the derivation 'aarch64-unknown-linux-android-ndk-toolchain-wrapper-24.0.8215888'
    … while evaluating the attribute 'bintools' of the derivation 'aarch64-unknown-linux-android-ndk-toolchain-wrapper-24.0.8215888'
    … while evaluating the attribute 'defaultNativeBuildInputs' of the derivation 'stdenv-linux'
    … while evaluating the attribute 'stdenv' of the derivation 'hello-aarch64-unknown-linux-android-2.12.1'
```

stdenv -> stdenv.cc -> bintools -> android-ndk-toolchain -> ndk -> platform-tools -> auto-patchelf-hook -> python3 -> zlib -> stdenv -> stdenv.cc -> ...

autoPatchelfHook was in buildInputs of platform-tools so we needed the host tools to build
it but platform-tools was a required tool
2022-12-15 21:55:22 +02:00
Pavol Rusnak
68889ed61f treewide: use quotes for url 2021-06-20 16:26:23 +02:00
Jonas Chevalier
c6b62f2381 mkShell: introduce packages argument (#122180)
The distinction between the inputs doesn't really make sense in the
mkShell context.  Technically speaking, we should be using the
nativeBuildInputs most of the time.

So in order to make this function more beginner-friendly, add "packages"
as an attribute, that maps to nativeBuildInputs.

This commit also updates all the uses in nixpkgs.
2021-05-13 19:17:29 +02:00
Morgan Jones
a7e5b070be androidenv: Allow multiple ndkVersions to be specified
Android is deprecating ndk.dir in favor of specifying exact NDK
version in Gradle configuration. Ensure that we can support multiple
NDKs, and link them into the location the Android Gradle Plugin expects.
2021-04-24 15:56:08 -06:00
numinit
5b91d4ab65 Rework androidenv package generation
androidenv did not previously write license files, which caused certain
gradle-based Android tools to fail. Restructure androidenv's list of
Android packages into a single repo.json file to prevent duplication
and enable us to extract the EULA texts, which we then hash with
builtins.hashString to produce the license files that Android gradle
tools look for.

Remove includeDocs and lldbVersions, as these have been removed
from the Android package repositories.

Improve documentation and examples.
2021-01-03 21:27:23 -07:00