git.iko.soy/typeable/nixpkgs
on master help sign in
androidenv: Add API sources
commita229fd4ce386b38478df7b413b4cfa834a41c3fd authortaku0 <mxxouy6x3m_github@tatapa.org> dateSun 9 Oct 2016, 19:11 (10 years ago) parent0974307
6 files changed+220−3
pkgs/development/mobile/androidenv/androidsdk.nix+18−1 pkgs/development/mobile/androidenv/default.nix+6−2 pkgs/development/mobile/androidenv/fetch.sh+1 pkgs/development/mobile/androidenv/generate-sources.sh+3 pkgs/development/mobile/androidenv/generate-sources.xsl+52 pkgs/development/mobile/androidenv/sources.nix+140
pkgs/development/mobile/androidenv/androidsdk.nix+18−1
@@ -1,8 +1,9 @@
11{ stdenv, stdenv_32bit, fetchurl, unzip, makeWrapper
2−, platformTools, buildTools, support, supportRepository, platforms, sysimages, addons
2+, platformTools, buildTools, support, supportRepository, platforms, sysimages, addons, sources
33, libX11, libXext, libXrender, libxcb, libXau, libXdmcp, libXtst, mesa, alsaLib
44, freetype, fontconfig, glib, gtk2, atk, file, jdk, coreutils, libpulseaudio, dbus
55, zlib, glxinfo, xkeyboardconfig
6+, includeSources
67}:
78{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false, useGooglePlayServices ? false }:
89
@@ -165,6 +166,22 @@ stdenv.mkDerivation rec {
165166
166167 cd ../..
167168
169+ # Symlink required sources
170+ mkdir -p sources
171+ cd sources
172+
173+ ${if includeSources then
174+ stdenv.lib.concatMapStrings (platformVersion:
175+ if (builtins.hasAttr ("source_"+platformVersion) sources) then
176+ let
177+ source = builtins.getAttr ("source_"+platformVersion) sources;
178+ in
179+ "ln -s ${source}/* android-${platformVersion}\n"
180+ else "") platformVersions
181+ else ""}
182+
183+ cd ..
184+
168185 # Symlink required platforms
169186
170187 mkdir -p platforms
pkgs/development/mobile/androidenv/default.nix+6−2
@@ -1,4 +1,4 @@
1−{pkgs, pkgs_i686}:
1+{pkgs, pkgs_i686, includeSources ? true}:
22
33rec {
44 platformTools = import ./platform-tools.nix {
@@ -39,12 +39,16 @@ rec {
3939 inherit (pkgs) stdenv fetchurl unzip;
4040 };
4141
42+ sources = import ./sources.nix {
43+ inherit (pkgs) stdenv fetchurl unzip;
44+ };
45+
4246 androidsdk = import ./androidsdk.nix {
4347 inherit (pkgs) stdenv fetchurl unzip makeWrapper;
4448 inherit (pkgs) zlib glxinfo freetype fontconfig glib gtk2 atk mesa file alsaLib jdk coreutils libpulseaudio dbus;
4549 inherit (pkgs.xorg) libX11 libXext libXrender libxcb libXau libXdmcp libXtst xkeyboardconfig;
4650
47− inherit platformTools buildTools support supportRepository platforms sysimages addons;
51+ inherit platformTools buildTools support supportRepository platforms sysimages addons sources includeSources;
4852
4953 stdenv_32bit = pkgs_i686.stdenv;
5054 };
pkgs/development/mobile/androidenv/fetch.sh+1
@@ -12,3 +12,4 @@ curl -o sys-img.xml https://dl.google.com/android/repository/sys-img/andro
1212./generate-addons.sh
1313./generate-platforms.sh
1414./generate-sysimages.sh
15+./generate-sources.sh
pkgs/development/mobile/androidenv/generate-sources.shnew file+3
@@ -0,0 +1,3 @@
1+#!/bin/sh -e
2+
3+xsltproc generate-sources.xsl repository-11.xml > sources.nix
pkgs/development/mobile/androidenv/generate-sources.xslnew file+52
@@ -0,0 +1,52 @@
1+<?xml version="1.0"?>
2+
3+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4+ xmlns:sdk="http://schemas.android.com/sdk/android/repository/11">
5+
6+ <xsl:output omit-xml-declaration="yes" indent="no" />
7+
8+ <xsl:template name="repository-url">
9+ <xsl:variable name="raw-url" select="sdk:archives/sdk:archive/sdk:url"/>
10+ <xsl:choose>
11+ <xsl:when test="starts-with($raw-url, 'http')">
12+ <xsl:value-of select="$raw-url"/>
13+ </xsl:when>
14+ <xsl:otherwise>
15+ <xsl:text>https://dl.google.com/android/repository/</xsl:text>
16+ <xsl:value-of select="$raw-url"/>
17+ </xsl:otherwise>
18+ </xsl:choose>
19+ </xsl:template>
20+
21+ <xsl:template match="/sdk:sdk-repository">
22+# This file is generated from generate-sources.sh. DO NOT EDIT.
23+# Execute generate-sources.sh or fetch.sh to update the file.
24+{stdenv, fetchurl, unzip}:
25+
26+let
27+ buildSource = args:
28+ stdenv.mkDerivation (args // {
29+ buildInputs = [ unzip ];
30+ buildCommand = ''
31+ mkdir -p $out
32+ cd $out
33+ unzip $src
34+ '';
35+ });
36+in
37+{
38+<xsl:for-each select="sdk:source"><xsl:sort select="sdk:api-level" data-type="number"/>
39+ source_<xsl:value-of select="sdk:api-level" /> = buildSource {
40+ name = "android-source-<xsl:value-of select="sdk:api-level" />";
41+ src = fetchurl {
42+ url = <xsl:call-template name="repository-url"/>;
43+ sha1 = "<xsl:value-of select="sdk:archives/sdk:archive/sdk:checksum[@type='sha1']" />";
44+ };
45+ meta = {
46+ description = "Source code for Android API <xsl:value-of select="sdk:api-level" />";
47+ };
48+ };
49+</xsl:for-each>
50+}
51+</xsl:template>
52+</xsl:stylesheet>
pkgs/development/mobile/androidenv/sources.nixnew file+140
@@ -0,0 +1,140 @@
1+
2+# This file is generated from generate-sources.sh. DO NOT EDIT.
3+# Execute generate-sources.sh or fetch.sh to update the file.
4+{stdenv, fetchurl, unzip}:
5+
6+let
7+ buildSource = args:
8+ stdenv.mkDerivation (args // {
9+ buildInputs = [ unzip ];
10+ buildCommand = ''
11+ mkdir -p $out
12+ cd $out
13+ unzip $src
14+ '';
15+ });
16+in
17+{
18+
19+ source_14 = buildSource {
20+ name = "android-source-14";
21+ src = fetchurl {
22+ url = https://dl.google.com/android/repository/sources-14_r01.zip;
23+ sha1 = "eaf4ed7dcac46e68516a1b4aa5b0d9e5a39a7555";
24+ };
25+ meta = {
26+ description = "Source code for Android API 14";
27+ };
28+ };
29+
30+ source_15 = buildSource {
31+ name = "android-source-15";
32+ src = fetchurl {
33+ url = https://dl.google.com/android/repository/sources-15_r02.zip;
34+ sha1 = "e5992a5747c9590783fbbdd700337bf0c9f6b1fa";
35+ };
36+ meta = {
37+ description = "Source code for Android API 15";
38+ };
39+ };
40+
41+ source_16 = buildSource {
42+ name = "android-source-16";
43+ src = fetchurl {
44+ url = https://dl.google.com/android/repository/sources-16_r02.zip;
45+ sha1 = "0f83c14ed333c45d962279ab5d6bc98a0269ef84";
46+ };
47+ meta = {
48+ description = "Source code for Android API 16";
49+ };
50+ };
51+
52+ source_17 = buildSource {
53+ name = "android-source-17";
54+ src = fetchurl {
55+ url = https://dl.google.com/android/repository/sources-17_r01.zip;
56+ sha1 = "6f1f18cd2d2b1852d7f6892df9cee3823349d43a";
57+ };
58+ meta = {
59+ description = "Source code for Android API 17";
60+ };
61+ };
62+
63+ source_18 = buildSource {
64+ name = "android-source-18";
65+ src = fetchurl {
66+ url = https://dl.google.com/android/repository/sources-18_r01.zip;
67+ sha1 = "8b49fdf7433f4881a2bfb559b5dd05d8ec65fb78";
68+ };
69+ meta = {
70+ description = "Source code for Android API 18";
71+ };
72+ };
73+
74+ source_19 = buildSource {
75+ name = "android-source-19";
76+ src = fetchurl {
77+ url = https://dl.google.com/android/repository/sources-19_r02.zip;
78+ sha1 = "433a1d043ef77561571250e94cb7a0ef24a202e7";
79+ };
80+ meta = {
81+ description = "Source code for Android API 19";
82+ };
83+ };
84+
85+ source_20 = buildSource {
86+ name = "android-source-20";
87+ src = fetchurl {
88+ url = https://dl.google.com/android/repository/sources-20_r01.zip;
89+ sha1 = "8da3e40f2625f9f7ef38b7e403f49f67226c0d76";
90+ };
91+ meta = {
92+ description = "Source code for Android API 20";
93+ };
94+ };
95+
96+ source_21 = buildSource {
97+ name = "android-source-21";
98+ src = fetchurl {
99+ url = https://dl.google.com/android/repository/sources-21_r01.zip;
100+ sha1 = "137a5044915d32bea297a8c1552684802bbc2e25";
101+ };
102+ meta = {
103+ description = "Source code for Android API 21";
104+ };
105+ };
106+
107+ source_22 = buildSource {
108+ name = "android-source-22";
109+ src = fetchurl {
110+ url = https://dl.google.com/android/repository/sources-22_r01.zip;
111+ sha1 = "98320e13976d11597a4a730a8d203ac9a03ed5a6";
112+ };
113+ meta = {
114+ description = "Source code for Android API 22";
115+ };
116+ };
117+
118+ source_23 = buildSource {
119+ name = "android-source-23";
120+ src = fetchurl {
121+ url = https://dl.google.com/android/repository/sources-23_r01.zip;
122+ sha1 = "b0f15da2762b42f543c5e364c2b15b198cc99cc2";
123+ };
124+ meta = {
125+ description = "Source code for Android API 23";
126+ };
127+ };
128+
129+ source_24 = buildSource {
130+ name = "android-source-24";
131+ src = fetchurl {
132+ url = https://dl.google.com/android/repository/sources-24_r01.zip;
133+ sha1 = "6b96115830a83d654479f32ce4b724ca9011148b";
134+ };
135+ meta = {
136+ description = "Source code for Android API 24";
137+ };
138+ };
139+
140+}