Commit Graph

79 Commits

Author SHA1 Message Date
Rohan
9e22abf3f7 androidenv: generate metadata correctly for abi variants
Because a single abi such as x86_64 can have multiple image variants which are not distinguished by checking only the
first tag. Android API 36x were particularly affected as they have both 4kb and 16kb memory page images.

Remove the inconsistent use of `tag` to determine the image path and ID. Instead the path is uniquely determined from
the source XML metadata's location while the `id` uses part of Google's `path` ID.

The `repo.json` is updated incrementally and the last version which was not affected by these issues was `a137f263af92`
so it has been regenerated based on that version.
2026-08-11 12:14:25 +12:00
Emily
fdb820602b treewide: drop simple x86_64-darwin mentions
To reproduce:

    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: nix-x86_64-darwin
          language: nix
          rule:
            any:
              - pattern: "\"x86_64-darwin\""
                kind: list_expression > string_expression
              - pattern:
                  context: "{ \"x86_64-darwin\" = $EXPR; }"
                  selector: binding
              - pattern:
                  context: "{ x86_64-darwin = $EXPR; }"
                  selector: binding
          fix:
            template: ""
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-first-x86_64-darwin
          language: json
          rule:
            kind: object > pair:nth-child(1)
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandEnd: { regex: "," }
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-x86_64-darwin
          language: json
          rule:
            kind: object > pair
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandStart: { regex: "," }
        ' pkgs
    $ git restore pkgs/by-name/om/omnix/package.nix
    $ git diff --name-only -z \
        | nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
            -c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
    $ treefmt
2026-07-15 03:58:16 +01:00
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
Alexandre Esteves
988d4becb0 androidenv.composeAndroidPackages: fix eval when minor versions are specified 2025-11-05 01:42:39 +00:00
Yueh-Shun Li
e1f3d9e0ae androidenv: fix name overriding
Use `overrideAttrs` to specify the FOD name we want,
instead of specifying `pname` and `version`
and expect a broken overrideAttrs that won't update `name`.
2025-11-04 02:25:57 +08:00
Alexandre Esteves
f4e08271a6 Fix parse when the platform version contains a minor component 2025-10-13 21:35:39 +01: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
Morgan Jones
843384b7fe androidenv: apply meta to Android fetchurl calls
This sets an unfree license, which already applied to everything else in
androidenv, preventing accidental caching on Hydra.
2025-08-17 23:01:19 -07:00
Wolfgang Walther
b2b3b4b768 androidsdk: move throw behind meta.license check
This allows evaluating the package's meta attribute without triggering
the throw, thus making it possible to list the package in the search
results. It also avoids CI falling over with this attribute.
2025-07-19 13:09:48 +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
a59e06abc4 androidenv: fix weird package naming and add versions
Some of the system images and NDK packages looked like:
`androidenv.androidPkgs.all.system_images.v35.google_apis_playstore.x_86___64`.
`androidenv.androidPkgs.all.packages.ndk.v21_0_6011959_rc_2`

Now they look like:
`androidenv.androidPkgs.all.system-images.v35.google_apis_playstore.x86_64`.
`androidenv.androidPkgs.all.packages.ndk.v21_0_6011959-rc2`

They should also have the versions correctly attached now for s.n.o.
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
63ebb67f9c androidenv: prefer local build for fetching packages 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
77af3a074d androidenv: compose-android-packages: remove null synonym to if-supported 2025-03-29 22:13:03 +05:30
Morgan Jones
3c13841124 androidenv: nixfmt 2025-03-29 22:13:03 +05:30
Morgan Jones
a1eefcb9b4 androidenv: add recurseIntoAttrs to packages 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
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
Artturin
facdea6901 androidenv: updates for Android API 35 (#336113) 2024-10-09 23:19:05 +03:00
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
Hadi
a551cfdc3e androidenv: updates for Android API 35 2024-08-20 15:42:13 -04:00
Morgan Jones
88ef7a8598 {android-studio,androidenv}: add withSdk passthru and androidPkgs
Rename androidPkgs_9_0 to androidPkgs, and treat it more like a "full"
androidenv package.
2024-06-03 23:01:44 -07:00
Sandro
01ec8ad898 Merge pull request #304716 from asyncmeow/fix-compose-android-packages
androidenv: fix compose-android-packages on non-x86_64 environments
2024-04-18 13:02:15 +02:00
pearl
0e2402e288 androidenv: fix compose-android-packages on non-x86_64 environments
This has always been possible, however the nix package previously checked against stdenv.system with only x86_64 architectures used.
2024-04-16 23:55:15 -04: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
Morgan Jones
1809b32877 androidenv: updates for Android API 34 2023-11-05 14:31:44 +01:00
Nick Cao
dbf5978a61 Merge pull request #248435 from hadilq/androidenv-fix-cmdline-beta-version
androidenv fix cmdline beta versions' problem
2023-08-13 00:25:14 -06:00
Hadi
430200fe06 androidenv update packages 2023-08-10 20:27:06 -04:00
Hadi
7c005a7b69 androidenv fix cmdline beta versions' problem 2023-08-10 20:09:15 -04:00
Hadi
3310972785 androidenv: update repo.json with a new strategy to expire 2023-05-12 18:33:46 -04:00
Hadi
077588ad1a androidenv: put a much nicer error message that includes the available options 2023-04-22 14:47:45 -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
Felix Buehler
bc3d5934d7 treewide: use lib.optionals 2023-02-14 19:11:59 +01: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
bceccb7f70 androidenv: Replace deploy-androidpackage.nix with deploy-androidpackages.nix 2022-12-31 11:21:40 -05:00
Hadi
2f688374e0 androidenv: fix missing packages in repo json (#208137) 2022-12-30 15:28:12 +02:00
jakobkukla
14c7a30161 androidenv: fix missing inherit os 2022-12-20 04:28:20 +01:00
jakobkukla
8851f074f8 androidenv: fix non-existent emulatorVersion 2022-12-20 04:28:20 +01:00
Vanilla
32c1e7d7db androidenv: fix missing inherit os in build-tools 2022-12-17 13:21:54 +08:00