nixnix-flake

Nix Flake: how to accept the Android SDK License


I'm trying to use nix flakes for android development.

This is my flake.nix:

{
  description = "test";
  outputs = { self, nixpkgs }: {
    packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
    devShell.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.mkShell {
      buildInputs = [
        nixpkgs.legacyPackages.x86_64-linux.androidenv.androidPkgs_9_0.androidsdk
      ];
    };
  };
}

Running nix develop gives me this message:

       You must accept the following licenses:
         - android-sdk-license

       by setting nixpkgs config option 'android_sdk.accept_license = true;'.

How can I pass this option to nixpkgs when using flakes?


Solution

  • legacyPackages does not let you pass config. You have to call Nixpkgs yourself:

    outputs = { self, nixpkgs, ... }:
      let pkgs = import nixpkgs {
            system = "x86_64-linux";
            config = {
              android_sdk.accept_license = true;
            };
      };
      in { /* ... */ pkgs.androidenv.androidPkgs_9_0.androidsdk
    # ...