4

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?

Peter Becich
  • 989
  • 3
  • 14
  • 30
Baju
  • 2,616
  • 1
  • 19
  • 29

1 Answers1

6

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
# ...
Baju
  • 2,616
  • 1
  • 19
  • 29
Robert Hensing
  • 6,708
  • 18
  • 23