uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
43
pkgs/development/mobile/abootimg/default.nix
Normal file
43
pkgs/development/mobile/abootimg/default.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ lib, stdenv, fetchFromGitHub, coreutils, cpio, findutils, gzip, makeWrapper, util-linux }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "abootimg";
|
||||
version = "0.6";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ggrandou";
|
||||
repo = "abootimg";
|
||||
rev = "7e127fee6a3981f6b0a50ce9910267cd501e09d4";
|
||||
sha256 = "1qgx9fxwhylgnixzkz2mzv2707f65qq7rar2rsqak536vhig1z9a";
|
||||
};
|
||||
|
||||
strictDeps = true;
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ util-linux ];
|
||||
|
||||
postPatch = ''
|
||||
cat <<EOF > version.h
|
||||
#define VERSION_STR "${version}"
|
||||
EOF
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
install -D -m 755 abootimg $out/bin
|
||||
install -D -m444 ./debian/abootimg.1 $out/share/man/man1/abootimg.1;
|
||||
|
||||
install -D -m 755 abootimg-pack-initrd $out/bin
|
||||
wrapProgram $out/bin/abootimg-pack-initrd --prefix PATH : ${lib.makeBinPath [ coreutils cpio findutils gzip ]}
|
||||
|
||||
install -D -m 755 abootimg-unpack-initrd $out/bin
|
||||
wrapProgram $out/bin/abootimg-unpack-initrd --prefix PATH : ${lib.makeBinPath [ cpio gzip ]}
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/ggrandou/abootimg";
|
||||
description = "Manipulate Android Boot Images";
|
||||
license = licenses.gpl2;
|
||||
platforms = platforms.linux;
|
||||
maintainers = [ maintainers.flokli ];
|
||||
};
|
||||
}
|
||||
43
pkgs/development/mobile/adb-sync/default.nix
Normal file
43
pkgs/development/mobile/adb-sync/default.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ lib, stdenv, fetchFromGitHub, python3, platform-tools, makeWrapper
|
||||
, socat, go-mtpfs, adbfs-rootless
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "adb-sync-unstable";
|
||||
version = "2019-01-01";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "google";
|
||||
repo = "adb-sync";
|
||||
rev = "fb7c549753de7a5579ed3400dd9f8ac71f7bf1b1";
|
||||
sha256 = "1kfpdqs8lmnh144jcm1qmfnmigzrbrz5lvwvqqb7021b2jlf69cl";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ python3 ];
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = let
|
||||
dependencies = lib.makeBinPath [ platform-tools socat go-mtpfs adbfs-rootless ];
|
||||
in ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cp adb-{sync,channel} $out/bin
|
||||
|
||||
wrapProgram $out/bin/adb-sync --suffix PATH : "${dependencies}"
|
||||
wrapProgram $out/bin/adb-channel --suffix PATH : "${dependencies}"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A tool to synchronise files between a PC and an Android devices using ADB (Android Debug Bridge)";
|
||||
homepage = "https://github.com/google/adb-sync";
|
||||
license = licenses.asl20;
|
||||
platforms = platforms.unix;
|
||||
hydraPlatforms = [];
|
||||
maintainers = with maintainers; [ scolobb ma27 ];
|
||||
};
|
||||
}
|
||||
42
pkgs/development/mobile/adbfs-rootless/default.nix
Normal file
42
pkgs/development/mobile/adbfs-rootless/default.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{ lib, stdenv, fetchFromGitHub, fetchpatch, pkg-config, fuse, adb }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "adbfs-rootless";
|
||||
version = "2016-10-02";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "spion";
|
||||
repo = "adbfs-rootless";
|
||||
rev = "b58963430e40c9246710a16cec58e7ffc88baa48";
|
||||
sha256 = "1kjibl86k6pf7vciwaaxwv5m4q28zdpd2g7yhp71av32jq6j3wm8";
|
||||
};
|
||||
|
||||
patches = [
|
||||
(fetchpatch {
|
||||
# https://github.com/spion/adbfs-rootless/issues/14
|
||||
url = "https://github.com/kronenpj/adbfs-rootless/commit/35f87ce0a7aeddaaad118daed3022e01453b838d.patch";
|
||||
sha256 = "1iigla74n3hphnyx9ffli9wqk7v71ylvsxama868czlg7851jqj9";
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ fuse ];
|
||||
|
||||
postPatch = ''
|
||||
# very ugly way of replacing the adb calls
|
||||
sed -e 's|"adb |"${adb}/bin/adb |g' \
|
||||
-i adbfs.cpp
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -D adbfs $out/bin/adbfs
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Mount Android phones on Linux with adb, no root required";
|
||||
inherit (src.meta) homepage;
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ Profpatsch ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
2
pkgs/development/mobile/androidenv/.gitignore
vendored
Normal file
2
pkgs/development/mobile/androidenv/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/xml
|
||||
local.properties
|
||||
6
pkgs/development/mobile/androidenv/README.md
Normal file
6
pkgs/development/mobile/androidenv/README.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# How to update
|
||||
|
||||
1. `./fetchrepo.sh`
|
||||
2. `./mkrepo.sh`
|
||||
3. Check the `repo.json` diff for new stable versions of `tools`, `platform-tools`, `build-tools`, `emulator` and/or `ndk`
|
||||
4. Update the relevant argument defaults in `compose-android-packages.nix`
|
||||
48
pkgs/development/mobile/androidenv/build-app.nix
Normal file
48
pkgs/development/mobile/androidenv/build-app.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{ composeAndroidPackages, stdenv, lib, ant, jdk, gnumake, gawk }:
|
||||
|
||||
{ name
|
||||
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
|
||||
, antFlags ? ""
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null;
|
||||
|
||||
let
|
||||
androidSdkFormalArgs = builtins.functionArgs composeAndroidPackages;
|
||||
androidArgs = builtins.intersectAttrs androidSdkFormalArgs args;
|
||||
androidsdk = (composeAndroidPackages androidArgs).androidsdk;
|
||||
|
||||
extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs);
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
name = lib.replaceChars [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot
|
||||
ANDROID_HOME = "${androidsdk}/libexec/android-sdk";
|
||||
buildInputs = [ jdk ant ];
|
||||
buildPhase = ''
|
||||
${lib.optionalString release ''
|
||||
# Provide key singing attributes
|
||||
( echo "key.store=${keyStore}"
|
||||
echo "key.alias=${keyAlias}"
|
||||
echo "key.store.password=${keyStorePassword}"
|
||||
echo "key.alias.password=${keyAliasPassword}"
|
||||
) >> ant.properties
|
||||
''}
|
||||
|
||||
export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it.
|
||||
|
||||
${lib.optionalString (args ? includeNDK && args.includeNDK) ''
|
||||
export GNUMAKE=${gnumake}/bin/make
|
||||
export NDK_HOST_AWK=${gawk}/bin/gawk
|
||||
${androidsdk}/libexec/android-sdk/ndk-bundle/ndk-build
|
||||
''}
|
||||
ant ${antFlags} ${if release then "release" else "debug"}
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv bin/*-${if release then "release" else "debug"}.apk $out
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products
|
||||
'';
|
||||
} // extraArgs)
|
||||
21
pkgs/development/mobile/androidenv/build-tools.nix
Normal file
21
pkgs/development/mobile/androidenv/build-tools.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{deployAndroidPackage, lib, package, os, autoPatchelfHook, makeWrapper, pkgs, pkgs_i686}:
|
||||
|
||||
deployAndroidPackage {
|
||||
inherit package os;
|
||||
buildInputs = [ makeWrapper ] ++
|
||||
lib.optionals (os == "linux") [ autoPatchelfHook pkgs.glibc pkgs.zlib pkgs.ncurses5 pkgs_i686.glibc pkgs_i686.zlib pkgs_i686.ncurses5 pkgs.libcxx ];
|
||||
patchInstructions = ''
|
||||
${lib.optionalString (os == "linux") ''
|
||||
addAutoPatchelfSearchPath $packageBaseDir/lib
|
||||
if [[ -d $packageBaseDir/lib64 ]]; then
|
||||
addAutoPatchelfSearchPath $packageBaseDir/lib64
|
||||
autoPatchelf --no-recurse $packageBaseDir/lib64
|
||||
fi
|
||||
autoPatchelf --no-recurse $packageBaseDir
|
||||
''}
|
||||
|
||||
wrapProgram $PWD/mainDexClasses \
|
||||
--prefix PATH : ${pkgs.jdk8}/bin
|
||||
'';
|
||||
noAuditTmpdir = true; # The checker script gets confused by the build-tools path that is incorrectly identified as a reference to /build
|
||||
}
|
||||
10
pkgs/development/mobile/androidenv/cmake.nix
Normal file
10
pkgs/development/mobile/androidenv/cmake.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{deployAndroidPackage, lib, package, os, autoPatchelfHook, pkgs, stdenv}:
|
||||
|
||||
deployAndroidPackage {
|
||||
inherit package os;
|
||||
nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
|
||||
buildInputs = lib.optional (os == "linux") [ pkgs.stdenv.cc.libc pkgs.stdenv.cc.cc pkgs.ncurses5 ];
|
||||
patchInstructions = lib.optionalString (os == "linux") ''
|
||||
autoPatchelf $packageBaseDir/bin
|
||||
'';
|
||||
}
|
||||
321
pkgs/development/mobile/androidenv/compose-android-packages.nix
Normal file
321
pkgs/development/mobile/androidenv/compose-android-packages.nix
Normal file
|
|
@ -0,0 +1,321 @@
|
|||
{ requireFile, autoPatchelfHook, pkgs, pkgsHostHost, pkgs_i686
|
||||
, licenseAccepted ? false
|
||||
}:
|
||||
|
||||
{ toolsVersion ? "26.1.1"
|
||||
, platformToolsVersion ? "33.0.1"
|
||||
, buildToolsVersions ? [ "32.0.0" ]
|
||||
, includeEmulator ? false
|
||||
, emulatorVersion ? "31.3.7"
|
||||
, platformVersions ? []
|
||||
, includeSources ? false
|
||||
, includeSystemImages ? false
|
||||
, systemImageTypes ? [ "google_apis_playstore" ]
|
||||
, abiVersions ? [ "armeabi-v7a" ]
|
||||
, cmakeVersions ? [ ]
|
||||
, includeNDK ? false
|
||||
, ndkVersion ? "24.0.8215888"
|
||||
, ndkVersions ? [ndkVersion]
|
||||
, useGoogleAPIs ? false
|
||||
, useGoogleTVAddOns ? false
|
||||
, includeExtras ? []
|
||||
, repoJson ? ./repo.json
|
||||
, repoXmls ? null
|
||||
, extraLicenses ? []
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) stdenv lib fetchurl;
|
||||
inherit (pkgs.buildPackages) makeWrapper unzip;
|
||||
|
||||
# Determine the Android os identifier from Nix's system identifier
|
||||
os = if stdenv.system == "x86_64-linux" then "linux"
|
||||
else if stdenv.system == "x86_64-darwin" then "macosx"
|
||||
else throw "No Android SDK tarballs are available for system architecture: ${stdenv.system}";
|
||||
|
||||
# Uses mkrepo.rb to create a repo spec.
|
||||
mkRepoJson = { packages ? [], images ? [], addons ? [] }: let
|
||||
mkRepoRuby = (pkgs.ruby.withPackages (pkgs: with pkgs; [ slop nokogiri ]));
|
||||
mkRepoRubyArguments = lib.lists.flatten [
|
||||
(builtins.map (package: ["--packages" "${package}"]) packages)
|
||||
(builtins.map (image: ["--images" "${image}"]) images)
|
||||
(builtins.map (addon: ["--addons" "${addon}"]) addons)
|
||||
];
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "androidenv-repo-json";
|
||||
buildInputs = [ mkRepoRuby ];
|
||||
preferLocalBuild = true;
|
||||
unpackPhase = "true";
|
||||
buildPhase = ''
|
||||
ruby ${./mkrepo.rb} ${lib.escapeShellArgs mkRepoRubyArguments} > repo.json
|
||||
'';
|
||||
installPhase = ''
|
||||
mv repo.json $out
|
||||
'';
|
||||
};
|
||||
|
||||
# Reads the repo JSON. If repoXmls is provided, will build a repo JSON into the Nix store.
|
||||
repo = if repoXmls != null then
|
||||
let
|
||||
repoXmlSpec = {
|
||||
packages = repoXmls.packages or [];
|
||||
images = repoXmls.images or [];
|
||||
addons = repoXmls.addons or [];
|
||||
};
|
||||
in
|
||||
lib.importJSON "${mkRepoJson repoXmlSpec}"
|
||||
else
|
||||
lib.importJSON repoJson;
|
||||
|
||||
# Converts all 'archives' keys in a repo spec to fetchurl calls.
|
||||
fetchArchives = attrSet:
|
||||
lib.attrsets.mapAttrsRecursive
|
||||
(path: value:
|
||||
if (builtins.elemAt path ((builtins.length path) - 1)) == "archives" then
|
||||
(builtins.listToAttrs
|
||||
(builtins.map
|
||||
(archive: lib.attrsets.nameValuePair archive.os (fetchurl { inherit (archive) url sha1; })) value))
|
||||
else value
|
||||
)
|
||||
attrSet;
|
||||
|
||||
# Converts the repo attrset into fetch calls
|
||||
packages = fetchArchives repo.packages;
|
||||
system-images-packages = fetchArchives repo.images;
|
||||
addons = {
|
||||
addons = fetchArchives repo.addons;
|
||||
extras = fetchArchives repo.extras;
|
||||
};
|
||||
|
||||
# Converts a license name to a list of license texts.
|
||||
mkLicenses = licenseName: repo.licenses.${licenseName};
|
||||
|
||||
# Converts a list of license names to a flattened list of license texts.
|
||||
# Just used for displaying licenses.
|
||||
mkLicenseTexts = licenseNames:
|
||||
lib.lists.flatten
|
||||
(builtins.map
|
||||
(licenseName:
|
||||
builtins.map
|
||||
(licenseText: "--- ${licenseName} ---\n${licenseText}")
|
||||
(mkLicenses licenseName))
|
||||
licenseNames);
|
||||
|
||||
# Converts a license name to a list of license hashes.
|
||||
mkLicenseHashes = licenseName:
|
||||
builtins.map
|
||||
(licenseText: builtins.hashString "sha1" licenseText)
|
||||
(mkLicenses licenseName);
|
||||
|
||||
# The list of all license names we're accepting. Put android-sdk-license there
|
||||
# by default.
|
||||
licenseNames = lib.lists.unique ([
|
||||
"android-sdk-license"
|
||||
] ++ extraLicenses);
|
||||
in
|
||||
rec {
|
||||
deployAndroidPackage = import ./deploy-androidpackage.nix {
|
||||
inherit stdenv unzip;
|
||||
};
|
||||
|
||||
platform-tools = import ./platform-tools.nix {
|
||||
inherit deployAndroidPackage autoPatchelfHook pkgs lib;
|
||||
os = if stdenv.system == "aarch64-darwin" then "macosx" else os; # "macosx" is a universal binary here
|
||||
package = packages.platform-tools.${platformToolsVersion};
|
||||
};
|
||||
|
||||
build-tools = map (version:
|
||||
import ./build-tools.nix {
|
||||
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgs_i686 lib;
|
||||
package = packages.build-tools.${version};
|
||||
}
|
||||
) buildToolsVersions;
|
||||
|
||||
emulator = import ./emulator.nix {
|
||||
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgs_i686 lib;
|
||||
package = packages.emulator.${emulatorVersion};
|
||||
};
|
||||
|
||||
platforms = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = packages.platforms.${version};
|
||||
}
|
||||
) platformVersions;
|
||||
|
||||
sources = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = packages.sources.${version};
|
||||
}
|
||||
) platformVersions;
|
||||
|
||||
system-images = lib.flatten (map (apiVersion:
|
||||
map (type:
|
||||
map (abiVersion:
|
||||
if lib.hasAttrByPath [apiVersion type abiVersion] system-images-packages then
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = system-images-packages.${apiVersion}.${type}.${abiVersion};
|
||||
# Patch 'google_apis' system images so they're recognized by the sdk.
|
||||
# Without this, `android list targets` shows 'Tag/ABIs : no ABIs' instead
|
||||
# of 'Tag/ABIs : google_apis*/*' and the emulator fails with an ABI-related error.
|
||||
patchInstructions = lib.optionalString (lib.hasPrefix "google_apis" type) ''
|
||||
sed -i '/^Addon.Vendor/d' source.properties
|
||||
'';
|
||||
}
|
||||
else []
|
||||
) abiVersions
|
||||
) systemImageTypes
|
||||
) platformVersions);
|
||||
|
||||
cmake = map (version:
|
||||
import ./cmake.nix {
|
||||
inherit deployAndroidPackage os autoPatchelfHook pkgs lib stdenv;
|
||||
package = packages.cmake.${version};
|
||||
}
|
||||
) cmakeVersions;
|
||||
|
||||
# Creates a NDK bundle.
|
||||
makeNdkBundle = ndkVersion:
|
||||
import ./ndk-bundle {
|
||||
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgsHostHost lib platform-tools stdenv;
|
||||
package = packages.ndk-bundle.${ndkVersion};
|
||||
};
|
||||
|
||||
# All NDK bundles.
|
||||
ndk-bundles = if includeNDK then map makeNdkBundle ndkVersions else [];
|
||||
|
||||
# The "default" NDK bundle.
|
||||
ndk-bundle = if includeNDK then lib.findFirst (x: x != null) null ndk-bundles else null;
|
||||
|
||||
google-apis = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = addons.addons.${version}.google_apis;
|
||||
}
|
||||
) (builtins.filter (platformVersion: platformVersion < "26") platformVersions); # API level 26 and higher include Google APIs by default
|
||||
|
||||
google-tv-addons = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = addons.addons.${version}.google_tv_addon;
|
||||
}
|
||||
) platformVersions;
|
||||
|
||||
# Function that automatically links all plugins for which multiple versions can coexist
|
||||
linkPlugins = {name, plugins}:
|
||||
lib.optionalString (plugins != []) ''
|
||||
mkdir -p ${name}
|
||||
${lib.concatMapStrings (plugin: ''
|
||||
ln -s ${plugin}/libexec/android-sdk/${name}/* ${name}
|
||||
'') plugins}
|
||||
'';
|
||||
|
||||
# Function that automatically links all NDK plugins.
|
||||
linkNdkPlugins = {name, plugins, rootName ? name}:
|
||||
lib.optionalString (plugins != []) ''
|
||||
mkdir -p ${rootName}
|
||||
${lib.concatMapStrings (plugin: ''
|
||||
ln -s ${plugin}/libexec/android-sdk/${name} ${rootName}/${plugin.version}
|
||||
'') plugins}
|
||||
'';
|
||||
|
||||
# Function that automatically links a plugin for which only one version exists
|
||||
linkPlugin = {name, plugin, check ? true}:
|
||||
lib.optionalString check ''
|
||||
ln -s ${plugin}/libexec/android-sdk/* ${name}
|
||||
'';
|
||||
|
||||
# Links all plugins related to a requested platform
|
||||
linkPlatformPlugins = {name, plugins, check}:
|
||||
lib.optionalString check ''
|
||||
mkdir -p ${name}
|
||||
${lib.concatMapStrings (plugin: ''
|
||||
ln -s ${plugin}/libexec/android-sdk/${name}/* ${name}
|
||||
'') plugins}
|
||||
''; # */
|
||||
|
||||
# This derivation deploys the tools package and symlinks all the desired
|
||||
# plugins that we want to use. If the license isn't accepted, prints all the licenses
|
||||
# requested and throws.
|
||||
androidsdk = if !licenseAccepted then throw ''
|
||||
${builtins.concatStringsSep "\n\n" (mkLicenseTexts licenseNames)}
|
||||
|
||||
You must accept the following licenses:
|
||||
${lib.concatMapStringsSep "\n" (str: " - ${str}") licenseNames}
|
||||
|
||||
by setting nixpkgs config option 'android_sdk.accept_license = true;'.
|
||||
'' else import ./tools.nix {
|
||||
inherit deployAndroidPackage requireFile packages toolsVersion autoPatchelfHook makeWrapper os pkgs pkgs_i686 lib;
|
||||
|
||||
postInstall = ''
|
||||
# Symlink all requested plugins
|
||||
${linkPlugin { name = "platform-tools"; plugin = platform-tools; }}
|
||||
${linkPlugins { name = "build-tools"; plugins = build-tools; }}
|
||||
${linkPlugin { name = "emulator"; plugin = emulator; check = includeEmulator; }}
|
||||
${linkPlugins { name = "platforms"; plugins = platforms; }}
|
||||
${linkPlatformPlugins { name = "sources"; plugins = sources; check = includeSources; }}
|
||||
${linkPlugins { name = "cmake"; plugins = cmake; }}
|
||||
${linkNdkPlugins { name = "ndk-bundle"; rootName = "ndk"; plugins = ndk-bundles; }}
|
||||
${linkPlugin { name = "ndk-bundle"; plugin = ndk-bundle; check = includeNDK; }}
|
||||
|
||||
${lib.optionalString includeSystemImages ''
|
||||
mkdir -p system-images
|
||||
${lib.concatMapStrings (system-image: ''
|
||||
apiVersion=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*))
|
||||
type=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*/*))
|
||||
mkdir -p system-images/$apiVersion/$type
|
||||
ln -s ${system-image}/libexec/android-sdk/system-images/$apiVersion/$type/* system-images/$apiVersion/$type
|
||||
'') system-images}
|
||||
''}
|
||||
|
||||
${linkPlatformPlugins { name = "add-ons"; plugins = google-apis; check = useGoogleAPIs; }}
|
||||
${linkPlatformPlugins { name = "add-ons"; plugins = google-apis; check = useGoogleTVAddOns; }}
|
||||
|
||||
# Link extras
|
||||
${lib.concatMapStrings (identifier:
|
||||
let
|
||||
path = addons.extras.${identifier}.path;
|
||||
addon = deployAndroidPackage {
|
||||
inherit os;
|
||||
package = addons.extras.${identifier};
|
||||
};
|
||||
in
|
||||
''
|
||||
targetDir=$(dirname ${path})
|
||||
mkdir -p $targetDir
|
||||
ln -s ${addon}/libexec/android-sdk/${path} $targetDir
|
||||
'') includeExtras}
|
||||
|
||||
# Expose common executables in bin/
|
||||
mkdir -p $out/bin
|
||||
find $PWD/tools -not -path '*/\.*' -type f -executable -mindepth 1 -maxdepth 1 | while read i
|
||||
do
|
||||
ln -s $i $out/bin
|
||||
done
|
||||
|
||||
find $PWD/tools/bin -not -path '*/\.*' -type f -executable -mindepth 1 -maxdepth 1 | while read i
|
||||
do
|
||||
ln -s $i $out/bin
|
||||
done
|
||||
|
||||
for i in ${platform-tools}/bin/*
|
||||
do
|
||||
ln -s $i $out/bin
|
||||
done
|
||||
|
||||
# Write licenses
|
||||
mkdir -p licenses
|
||||
${lib.concatMapStrings (licenseName:
|
||||
let
|
||||
licenseHashes = builtins.concatStringsSep "\n" (mkLicenseHashes licenseName);
|
||||
licenseHashFile = pkgs.writeText "androidenv-${licenseName}" licenseHashes;
|
||||
in
|
||||
''
|
||||
ln -s ${licenseHashFile} licenses/${licenseName}
|
||||
'') licenseNames}
|
||||
'';
|
||||
};
|
||||
}
|
||||
26
pkgs/development/mobile/androidenv/default.nix
Normal file
26
pkgs/development/mobile/androidenv/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ config, pkgs ? import <nixpkgs> {}, pkgsHostHost ? pkgs.pkgsHostHost
|
||||
, pkgs_i686 ? import <nixpkgs> { system = "i686-linux"; }
|
||||
, licenseAccepted ? config.android_sdk.accept_license or false
|
||||
}:
|
||||
|
||||
rec {
|
||||
composeAndroidPackages = import ./compose-android-packages.nix {
|
||||
inherit (pkgs) requireFile autoPatchelfHook;
|
||||
inherit pkgs pkgsHostHost pkgs_i686 licenseAccepted;
|
||||
};
|
||||
|
||||
buildApp = import ./build-app.nix {
|
||||
inherit (pkgs) stdenv lib jdk ant gnumake gawk;
|
||||
inherit composeAndroidPackages;
|
||||
};
|
||||
|
||||
emulateApp = import ./emulate-app.nix {
|
||||
inherit (pkgs) stdenv lib runtimeShell;
|
||||
inherit composeAndroidPackages;
|
||||
};
|
||||
|
||||
androidPkgs_9_0 = composeAndroidPackages {
|
||||
platformVersions = [ "28" ];
|
||||
abiVersions = [ "x86" "x86_64"];
|
||||
};
|
||||
}
|
||||
46
pkgs/development/mobile/androidenv/deploy-androidpackage.nix
Normal file
46
pkgs/development/mobile/androidenv/deploy-androidpackage.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{stdenv, unzip}:
|
||||
{package, os ? null, buildInputs ? [], patchInstructions ? "", meta ? {}, ...}@args:
|
||||
|
||||
let
|
||||
extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ];
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
pname = package.name;
|
||||
version = package.revision;
|
||||
src = if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all;
|
||||
buildInputs = [ unzip ] ++ buildInputs;
|
||||
preferLocalBuild = true;
|
||||
|
||||
# Most Android Zip packages have a root folder, but some don't. We unpack
|
||||
# the zip file in a folder and we try to discover whether it has a single root
|
||||
# folder. If this is the case, we adjust the current working folder.
|
||||
unpackPhase = ''
|
||||
mkdir extractedzip
|
||||
cd extractedzip
|
||||
unpackFile "$src"
|
||||
if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ]
|
||||
then
|
||||
cd "$(find . -mindepth 1 -maxdepth 1 -type d)"
|
||||
fi
|
||||
sourceRoot="$PWD"
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
packageBaseDir=$out/libexec/android-sdk/${package.path}
|
||||
mkdir -p $packageBaseDir
|
||||
cd $packageBaseDir
|
||||
cp -a $sourceRoot/* .
|
||||
${patchInstructions}
|
||||
'';
|
||||
|
||||
# We never attempt to strip. This is not required since we're doing binary
|
||||
# deployments. Moreover, some executables that have been patched with patchelf
|
||||
# may not work any longer after they have been stripped.
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
dontAutoPatchelf = true;
|
||||
|
||||
meta = {
|
||||
description = package.displayName;
|
||||
} // meta;
|
||||
} // extraParams)
|
||||
137
pkgs/development/mobile/androidenv/emulate-app.nix
Normal file
137
pkgs/development/mobile/androidenv/emulate-app.nix
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
{ composeAndroidPackages, stdenv, lib, runtimeShell }:
|
||||
{ name, app ? null
|
||||
, platformVersion ? "16", abiVersion ? "armeabi-v7a", systemImageType ? "default"
|
||||
, enableGPU ? false, extraAVDFiles ? []
|
||||
, package ? null, activity ? null
|
||||
, avdHomeDir ? null, sdkExtraArgs ? {}
|
||||
}:
|
||||
|
||||
let
|
||||
sdkArgs = {
|
||||
toolsVersion = "26.1.1";
|
||||
platformVersions = [ platformVersion ];
|
||||
includeEmulator = true;
|
||||
includeSystemImages = true;
|
||||
systemImageTypes = [ systemImageType ];
|
||||
abiVersions = [ abiVersion ];
|
||||
} // sdkExtraArgs;
|
||||
|
||||
sdk = (composeAndroidPackages sdkArgs).androidsdk;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
cat > $out/bin/run-test-emulator << "EOF"
|
||||
#!${runtimeShell} -e
|
||||
|
||||
# We need a TMPDIR
|
||||
if [ "$TMPDIR" = "" ]
|
||||
then
|
||||
export TMPDIR=/tmp
|
||||
fi
|
||||
|
||||
${if avdHomeDir == null then ''
|
||||
# Store the virtual devices somewhere else, instead of polluting a user's HOME directory
|
||||
export ANDROID_SDK_HOME=$(mktemp -d $TMPDIR/nix-android-vm-XXXX)
|
||||
'' else ''
|
||||
mkdir -p "${avdHomeDir}"
|
||||
export ANDROID_SDK_HOME="${avdHomeDir}"
|
||||
''}
|
||||
|
||||
# We need to specify the location of the Android SDK root folder
|
||||
export ANDROID_SDK_ROOT=${sdk}/libexec/android-sdk
|
||||
|
||||
# We have to look for a free TCP port
|
||||
|
||||
echo "Looking for a free TCP port in range 5554-5584" >&2
|
||||
|
||||
for i in $(seq 5554 2 5584)
|
||||
do
|
||||
if [ -z "$(${sdk}/libexec/android-sdk/platform-tools/adb devices | grep emulator-$i)" ]
|
||||
then
|
||||
port=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$port" ]
|
||||
then
|
||||
echo "Unfortunately, the emulator port space is exhausted!" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "We have a free TCP port: $port" >&2
|
||||
fi
|
||||
|
||||
export ANDROID_SERIAL="emulator-$port"
|
||||
|
||||
# Create a virtual android device for testing if it does not exist
|
||||
${sdk}/libexec/android-sdk/tools/bin/avdmanager list target
|
||||
|
||||
if [ "$(${sdk}/libexec/android-sdk/tools/android list avd | grep 'Name: device')" = "" ]
|
||||
then
|
||||
# Create a virtual android device
|
||||
yes "" | ${sdk}/libexec/android-sdk/tools/bin/avdmanager create avd -n device -k "system-images;android-${platformVersion};${systemImageType};${abiVersion}" $NIX_ANDROID_AVD_FLAGS
|
||||
|
||||
${lib.optionalString enableGPU ''
|
||||
# Enable GPU acceleration
|
||||
echo "hw.gpu.enabled=yes" >> $ANDROID_SDK_HOME/.android/avd/device.avd/config.ini
|
||||
''}
|
||||
|
||||
${lib.concatMapStrings (extraAVDFile: ''
|
||||
ln -sf ${extraAVDFile} $ANDROID_SDK_HOME/.android/avd/device.avd
|
||||
'') extraAVDFiles}
|
||||
fi
|
||||
|
||||
# Launch the emulator
|
||||
${sdk}/libexec/android-sdk/emulator/emulator -avd device -no-boot-anim -port $port $NIX_ANDROID_EMULATOR_FLAGS &
|
||||
|
||||
# Wait until the device has completely booted
|
||||
echo "Waiting until the emulator has booted the device and the package manager is ready..." >&2
|
||||
|
||||
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port wait-for-device
|
||||
|
||||
echo "Device state has been reached" >&2
|
||||
|
||||
while [ -z "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ]
|
||||
do
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "dev.bootcomplete property is 1" >&2
|
||||
|
||||
#while [ -z "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ]
|
||||
#do
|
||||
#sleep 5
|
||||
#done
|
||||
|
||||
#echo "sys.boot_completed property is 1" >&2
|
||||
|
||||
echo "ready" >&2
|
||||
|
||||
${lib.optionalString (app != null) ''
|
||||
# Install the App through the debugger, if it has not been installed yet
|
||||
|
||||
if [ -z "${package}" ] || [ "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
|
||||
then
|
||||
if [ -d "${app}" ]
|
||||
then
|
||||
appPath="$(echo ${app}/*.apk)"
|
||||
else
|
||||
appPath="${app}"
|
||||
fi
|
||||
|
||||
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port install "$appPath"
|
||||
fi
|
||||
|
||||
# Start the application
|
||||
${lib.optionalString (package != null && activity != null) ''
|
||||
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
|
||||
''}
|
||||
''}
|
||||
EOF
|
||||
chmod +x $out/bin/run-test-emulator
|
||||
'';
|
||||
}
|
||||
52
pkgs/development/mobile/androidenv/emulator.nix
Normal file
52
pkgs/development/mobile/androidenv/emulator.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{ deployAndroidPackage, lib, package, os, autoPatchelfHook, makeWrapper, pkgs, pkgs_i686 }:
|
||||
|
||||
deployAndroidPackage {
|
||||
inherit package os;
|
||||
buildInputs = [ makeWrapper ]
|
||||
++ lib.optionals (os == "linux") (with pkgs; [
|
||||
autoPatchelfHook
|
||||
glibc
|
||||
libcxx
|
||||
libGL
|
||||
libpulseaudio
|
||||
libuuid
|
||||
zlib
|
||||
ncurses5
|
||||
stdenv.cc.cc
|
||||
i686.glibc
|
||||
expat
|
||||
freetype
|
||||
nss
|
||||
nspr
|
||||
alsa-lib
|
||||
]) ++ (with pkgs.xorg; [
|
||||
libX11
|
||||
libXext
|
||||
libXdamage
|
||||
libXfixes
|
||||
libxcb
|
||||
libXcomposite
|
||||
libXcursor
|
||||
libXi
|
||||
libXrender
|
||||
libXtst
|
||||
]);
|
||||
patchInstructions = lib.optionalString (os == "linux") ''
|
||||
addAutoPatchelfSearchPath $packageBaseDir/lib
|
||||
addAutoPatchelfSearchPath $packageBaseDir/lib64
|
||||
addAutoPatchelfSearchPath $packageBaseDir/lib64/qt/lib
|
||||
# autoPatchelf is not detecting libuuid :(
|
||||
addAutoPatchelfSearchPath ${pkgs.libuuid.out}/lib
|
||||
autoPatchelf $out
|
||||
|
||||
# Wrap emulator so that it can load required libraries at runtime
|
||||
wrapProgram $out/libexec/android-sdk/emulator/emulator \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [
|
||||
pkgs.dbus
|
||||
pkgs.systemd
|
||||
]} \
|
||||
--set QT_XKB_CONFIG_ROOT ${pkgs.xkeyboard_config}/share/X11/xkb \
|
||||
--set QTCOMPOSE ${pkgs.xorg.libX11.out}/share/X11/locale
|
||||
'';
|
||||
dontMoveLib64 = true;
|
||||
}
|
||||
145
pkgs/development/mobile/androidenv/examples/shell.nix
Normal file
145
pkgs/development/mobile/androidenv/examples/shell.nix
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
{
|
||||
# If you copy this example out of nixpkgs, use these lines instead of the next.
|
||||
# This example pins nixpkgs: https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html
|
||||
/*nixpkgsSource ? (builtins.fetchTarball {
|
||||
name = "nixpkgs-20.09";
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz";
|
||||
sha256 = "1wg61h4gndm3vcprdcg7rc4s1v3jkm5xd7lw8r2f67w502y94gcy";
|
||||
}),
|
||||
pkgs ? import nixpkgsSource {},
|
||||
pkgs_i686 ? import nixpkgsSource { system = "i686-linux"; },*/
|
||||
|
||||
# If you want to use the in-tree version of nixpkgs:
|
||||
pkgs ? import ../../../../.. {},
|
||||
pkgs_i686 ? import ../../../../.. { system = "i686-linux"; },
|
||||
|
||||
config ? pkgs.config
|
||||
}:
|
||||
|
||||
# Copy this file to your Android project.
|
||||
let
|
||||
# Declaration of versions for everything. This is useful since these
|
||||
# versions may be used in multiple places in this Nix expression.
|
||||
android = {
|
||||
versions = {
|
||||
tools = "26.1.1";
|
||||
platformTools = "31.0.2";
|
||||
buildTools = "30.0.3";
|
||||
ndk = [
|
||||
"22.1.7171670"
|
||||
"21.3.6528147" # LTS NDK
|
||||
];
|
||||
cmake = "3.18.1";
|
||||
emulator = "30.6.3";
|
||||
};
|
||||
|
||||
platforms = ["23" "24" "25" "26" "27" "28" "29" "30"];
|
||||
abis = ["armeabi-v7a" "arm64-v8a"];
|
||||
extras = ["extras;google;gcm"];
|
||||
};
|
||||
|
||||
# If you copy this example out of nixpkgs, something like this will work:
|
||||
/*androidEnvNixpkgs = fetchTarball {
|
||||
name = "androidenv";
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/<fill me in from Git>.tar.gz";
|
||||
sha256 = "<fill me in with nix-prefetch-url --unpack>";
|
||||
};
|
||||
|
||||
androidEnv = pkgs.callPackage "${androidEnvNixpkgs}/pkgs/development/mobile/androidenv" {
|
||||
inherit config pkgs pkgs_i686;
|
||||
licenseAccepted = true;
|
||||
};*/
|
||||
|
||||
# Otherwise, just use the in-tree androidenv:
|
||||
androidEnv = pkgs.callPackage ./.. {
|
||||
inherit config pkgs pkgs_i686;
|
||||
licenseAccepted = true;
|
||||
};
|
||||
|
||||
androidComposition = androidEnv.composeAndroidPackages {
|
||||
toolsVersion = android.versions.tools;
|
||||
platformToolsVersion = android.versions.platformTools;
|
||||
buildToolsVersions = [android.versions.buildTools];
|
||||
platformVersions = android.platforms;
|
||||
abiVersions = android.abis;
|
||||
|
||||
includeSources = true;
|
||||
includeSystemImages = true;
|
||||
includeEmulator = true;
|
||||
emulatorVersion = android.versions.emulator;
|
||||
|
||||
includeNDK = true;
|
||||
ndkVersions = android.versions.ndk;
|
||||
cmakeVersions = [android.versions.cmake];
|
||||
|
||||
useGoogleAPIs = true;
|
||||
includeExtras = android.extras;
|
||||
|
||||
# If you want to use a custom repo JSON:
|
||||
# repoJson = ../repo.json;
|
||||
|
||||
# If you want to use custom repo XMLs:
|
||||
/*repoXmls = {
|
||||
packages = [ ../xml/repository2-1.xml ];
|
||||
images = [
|
||||
../xml/android-sys-img2-1.xml
|
||||
../xml/android-tv-sys-img2-1.xml
|
||||
../xml/android-wear-sys-img2-1.xml
|
||||
../xml/android-wear-cn-sys-img2-1.xml
|
||||
../xml/google_apis-sys-img2-1.xml
|
||||
../xml/google_apis_playstore-sys-img2-1.xml
|
||||
];
|
||||
addons = [ ../xml/addon2-1.xml ];
|
||||
};*/
|
||||
|
||||
# Accepting more licenses declaratively:
|
||||
extraLicenses = [
|
||||
# Already accepted for you with the global accept_license = true or
|
||||
# licenseAccepted = true on androidenv.
|
||||
# "android-sdk-license"
|
||||
|
||||
# These aren't, but are useful for more uncommon setups.
|
||||
"android-sdk-preview-license"
|
||||
"android-googletv-license"
|
||||
"android-sdk-arm-dbt-license"
|
||||
"google-gdk-license"
|
||||
"intel-android-extra-license"
|
||||
"intel-android-sysimage-license"
|
||||
"mips-android-sysimage-license"
|
||||
];
|
||||
};
|
||||
|
||||
androidSdk = androidComposition.androidsdk;
|
||||
platformTools = androidComposition.platform-tools;
|
||||
jdk = pkgs.jdk;
|
||||
in
|
||||
pkgs.mkShell rec {
|
||||
name = "androidenv-demo";
|
||||
packages = [ androidSdk platformTools jdk pkgs.android-studio ];
|
||||
|
||||
LANG = "C.UTF-8";
|
||||
LC_ALL = "C.UTF-8";
|
||||
JAVA_HOME = jdk.home;
|
||||
|
||||
# Note: ANDROID_HOME is deprecated. Use ANDROID_SDK_ROOT.
|
||||
ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
|
||||
ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle";
|
||||
|
||||
# Ensures that we don't have to use a FHS env by using the nix store's aapt2.
|
||||
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${android.versions.buildTools}/aapt2";
|
||||
|
||||
shellHook = ''
|
||||
# Add cmake to the path.
|
||||
cmake_root="$(echo "$ANDROID_SDK_ROOT/cmake/${android.versions.cmake}"*/)"
|
||||
export PATH="$cmake_root/bin:$PATH"
|
||||
|
||||
# Write out local.properties for Android Studio.
|
||||
cat <<EOF > local.properties
|
||||
# This file was automatically generated by nix-shell.
|
||||
sdk.dir=$ANDROID_SDK_ROOT
|
||||
ndk.dir=$ANDROID_NDK_ROOT
|
||||
cmake.dir=$cmake_root
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
|
||||
26
pkgs/development/mobile/androidenv/fetchrepo.sh
Executable file
26
pkgs/development/mobile/androidenv/fetchrepo.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl
|
||||
|
||||
die() {
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
fetch() {
|
||||
local url="https://dl.google.com/android/repository/$1"
|
||||
echo "$url -> $2"
|
||||
curl -s "$url" -o "$2" || die "Failed to fetch $url"
|
||||
}
|
||||
|
||||
pushd "$(dirname "$0")" &>/dev/null || exit 1
|
||||
|
||||
mkdir -p xml
|
||||
|
||||
fetch repository2-1.xml xml/repository2-1.xml
|
||||
for img in android android-tv android-wear android-wear-cn android-automotive google_apis google_apis_playstore
|
||||
do
|
||||
fetch sys-img/$img/sys-img2-1.xml xml/$img-sys-img2-1.xml
|
||||
done
|
||||
fetch addon2-1.xml xml/addon2-1.xml
|
||||
|
||||
popd &>/dev/null
|
||||
3
pkgs/development/mobile/androidenv/generate.sh
Executable file
3
pkgs/development/mobile/androidenv/generate.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
./fetchrepo.sh && ./mkrepo.sh
|
||||
321
pkgs/development/mobile/androidenv/mkrepo.rb
Normal file
321
pkgs/development/mobile/androidenv/mkrepo.rb
Normal file
|
|
@ -0,0 +1,321 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
require 'nokogiri'
|
||||
require 'slop'
|
||||
|
||||
# Returns a repo URL for a given package name.
|
||||
def repo_url value
|
||||
if value && value.start_with?('http')
|
||||
value
|
||||
elsif value
|
||||
"https://dl.google.com/android/repository/#{value}"
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a system image URL for a given system image name.
|
||||
def image_url value, dir
|
||||
if value && value.start_with?('http')
|
||||
value
|
||||
elsif value
|
||||
"https://dl.google.com/android/repository/sys-img/#{dir}/#{value}"
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a tuple of [type, revision, revision components] for a package node.
|
||||
def package_revision package
|
||||
type_details = package.at_css('> type-details')
|
||||
type = type_details.attributes['type']
|
||||
type &&= type.value
|
||||
|
||||
revision = nil
|
||||
components = nil
|
||||
|
||||
case type
|
||||
when 'generic:genericDetailsType', 'addon:extraDetailsType', 'addon:mavenType'
|
||||
major = text package.at_css('> revision > major')
|
||||
minor = text package.at_css('> revision > minor')
|
||||
micro = text package.at_css('> revision > micro')
|
||||
preview = text package.at_css('> revision > preview')
|
||||
|
||||
revision = ''
|
||||
components = []
|
||||
unless empty?(major)
|
||||
revision << major
|
||||
components << major
|
||||
end
|
||||
|
||||
unless empty?(minor)
|
||||
revision << ".#{minor}"
|
||||
components << minor
|
||||
end
|
||||
|
||||
unless empty?(micro)
|
||||
revision << ".#{micro}"
|
||||
components << micro
|
||||
end
|
||||
|
||||
unless empty?(preview)
|
||||
revision << "-rc#{preview}"
|
||||
components << preview
|
||||
end
|
||||
when 'sdk:platformDetailsType'
|
||||
codename = text type_details.at_css('> codename')
|
||||
api_level = text type_details.at_css('> api-level')
|
||||
revision = empty?(codename) ? api_level : codename
|
||||
components = [revision]
|
||||
when 'sdk:sourceDetailsType'
|
||||
api_level = text type_details.at_css('> api-level')
|
||||
revision, components = api_level, [api_level]
|
||||
when 'sys-img:sysImgDetailsType'
|
||||
codename = text type_details.at_css('> codename')
|
||||
api_level = text type_details.at_css('> api-level')
|
||||
id = text type_details.at_css('> tag > id')
|
||||
abi = text type_details.at_css('> abi')
|
||||
|
||||
revision = ''
|
||||
components = []
|
||||
if empty?(codename)
|
||||
revision << api_level
|
||||
components << api_level
|
||||
else
|
||||
revision << codename
|
||||
components << codename
|
||||
end
|
||||
|
||||
unless empty?(id)
|
||||
revision << "-#{id}"
|
||||
components << id
|
||||
end
|
||||
|
||||
unless empty?(abi)
|
||||
revision << "-#{abi}"
|
||||
components << abi
|
||||
end
|
||||
when 'addon:addonDetailsType' then
|
||||
api_level = text type_details.at_css('> api-level')
|
||||
id = text type_details.at_css('> tag > id')
|
||||
revision = api_level
|
||||
components = [api_level, id]
|
||||
end
|
||||
|
||||
[type, revision, components]
|
||||
end
|
||||
|
||||
# Returns a hash of archives for the specified package node.
|
||||
def package_archives package
|
||||
archives = {}
|
||||
package.css('> archives > archive').each do |archive|
|
||||
host_os = text archive.at_css('> host-os')
|
||||
host_os = 'all' if empty?(host_os)
|
||||
archives[host_os] = {
|
||||
'size' => Integer(text(archive.at_css('> complete > size'))),
|
||||
'sha1' => text(archive.at_css('> complete > checksum')),
|
||||
'url' => yield(text(archive.at_css('> complete > url')))
|
||||
}
|
||||
end
|
||||
archives
|
||||
end
|
||||
|
||||
# Returns the text from a node, or nil.
|
||||
def text node
|
||||
node ? node.text : nil
|
||||
end
|
||||
|
||||
# Nil or empty helper.
|
||||
def empty? value
|
||||
!value || value.empty?
|
||||
end
|
||||
|
||||
# Fixes up returned hashes by sorting keys.
|
||||
# Will also convert archives (e.g. {'linux' => {'sha1' => ...}, 'macosx' => ...} to
|
||||
# [{'os' => 'linux', 'sha1' => ...}, {'os' => 'macosx', ...}, ...].
|
||||
def fixup value
|
||||
Hash[value.map do |k, v|
|
||||
if k == 'archives' && v.is_a?(Hash)
|
||||
[k, v.map do |os, archive|
|
||||
fixup({'os' => os}.merge(archive))
|
||||
end]
|
||||
elsif v.is_a?(Hash)
|
||||
[k, fixup(v)]
|
||||
else
|
||||
[k, v]
|
||||
end
|
||||
end.sort {|(k1, v1), (k2, v2)| k1 <=> k2}]
|
||||
end
|
||||
|
||||
# Normalize the specified license text.
|
||||
# See: https://brash-snapper.glitch.me/ for how the munging works.
|
||||
def normalize_license license
|
||||
license = license.dup
|
||||
license.gsub!(/([^\n])\n([^\n])/m, '\1 \2')
|
||||
license.gsub!(/ +/, ' ')
|
||||
license
|
||||
end
|
||||
|
||||
# Gets all license texts, deduplicating them.
|
||||
def get_licenses doc
|
||||
licenses = {}
|
||||
doc.css('license[type="text"]').each do |license_node|
|
||||
license_id = license_node['id']
|
||||
if license_id
|
||||
licenses[license_id] ||= []
|
||||
licenses[license_id] |= [normalize_license(text(license_node))]
|
||||
end
|
||||
end
|
||||
licenses
|
||||
end
|
||||
|
||||
def parse_package_xml doc
|
||||
licenses = get_licenses doc
|
||||
packages = {}
|
||||
|
||||
doc.css('remotePackage').each do |package|
|
||||
name, _, version = package['path'].partition(';')
|
||||
next if version == 'latest'
|
||||
|
||||
type, revision, _ = package_revision(package)
|
||||
next unless revision
|
||||
|
||||
path = package['path'].tr(';', '/')
|
||||
display_name = text package.at_css('> display-name')
|
||||
uses_license = package.at_css('> uses-license')
|
||||
uses_license &&= uses_license['ref']
|
||||
archives = package_archives(package) {|url| repo_url url}
|
||||
|
||||
target = (packages[name] ||= {})
|
||||
target = (target[revision] ||= {})
|
||||
|
||||
target['name'] ||= name
|
||||
target['path'] ||= path
|
||||
target['revision'] ||= revision
|
||||
target['displayName'] ||= display_name
|
||||
target['license'] ||= uses_license if uses_license
|
||||
target['archives'] ||= {}
|
||||
merge target['archives'], archives
|
||||
end
|
||||
|
||||
[licenses, packages]
|
||||
end
|
||||
|
||||
def parse_image_xml doc
|
||||
licenses = get_licenses doc
|
||||
images = {}
|
||||
|
||||
doc.css('remotePackage[path^="system-images;"]').each do |package|
|
||||
type, revision, components = package_revision(package)
|
||||
next unless revision
|
||||
|
||||
path = package['path'].tr(';', '/')
|
||||
display_name = text package.at_css('> display-name')
|
||||
uses_license = package.at_css('> uses-license')
|
||||
uses_license &&= uses_license['ref']
|
||||
archives = package_archives(package) {|url| image_url url, components[-2]}
|
||||
|
||||
target = images
|
||||
components.each do |component|
|
||||
target = (target[component] ||= {})
|
||||
end
|
||||
|
||||
target['name'] ||= "system-image-#{revision}"
|
||||
target['path'] ||= path
|
||||
target['revision'] ||= revision
|
||||
target['displayName'] ||= display_name
|
||||
target['license'] ||= uses_license if uses_license
|
||||
target['archives'] ||= {}
|
||||
merge target['archives'], archives
|
||||
end
|
||||
|
||||
[licenses, images]
|
||||
end
|
||||
|
||||
def parse_addon_xml doc
|
||||
licenses = get_licenses doc
|
||||
addons, extras = {}, {}
|
||||
|
||||
doc.css('remotePackage').each do |package|
|
||||
type, revision, components = package_revision(package)
|
||||
next unless revision
|
||||
|
||||
path = package['path'].tr(';', '/')
|
||||
display_name = text package.at_css('> display-name')
|
||||
uses_license = package.at_css('> uses-license')
|
||||
uses_license &&= uses_license['ref']
|
||||
archives = package_archives(package) {|url| repo_url url}
|
||||
|
||||
case type
|
||||
when 'addon:addonDetailsType'
|
||||
name = components.last
|
||||
target = addons
|
||||
|
||||
# Hack for Google APIs 25 r1, which displays as 23 for some reason
|
||||
archive_name = text package.at_css('> archives > archive > complete > url')
|
||||
if archive_name == 'google_apis-25_r1.zip'
|
||||
path = 'add-ons/addon-google_apis-google-25'
|
||||
revision = '25'
|
||||
components = [revision, components.last]
|
||||
end
|
||||
when 'addon:extraDetailsType', 'addon:mavenType'
|
||||
name = package['path'].tr(';', '-')
|
||||
components = [package['path']]
|
||||
target = extras
|
||||
end
|
||||
|
||||
components.each do |component|
|
||||
target = (target[component] ||= {})
|
||||
end
|
||||
|
||||
target['name'] ||= name
|
||||
target['path'] ||= path
|
||||
target['revision'] ||= revision
|
||||
target['displayName'] ||= display_name
|
||||
target['license'] ||= uses_license if uses_license
|
||||
target['archives'] ||= {}
|
||||
merge target['archives'], archives
|
||||
end
|
||||
|
||||
[licenses, addons, extras]
|
||||
end
|
||||
|
||||
def merge dest, src
|
||||
dest.merge! src
|
||||
end
|
||||
|
||||
opts = Slop.parse do |o|
|
||||
o.array '-p', '--packages', 'packages repo XMLs to parse'
|
||||
o.array '-i', '--images', 'system image repo XMLs to parse'
|
||||
o.array '-a', '--addons', 'addon repo XMLs to parse'
|
||||
end
|
||||
|
||||
result = {
|
||||
licenses: {},
|
||||
packages: {},
|
||||
images: {},
|
||||
addons: {},
|
||||
extras: {}
|
||||
}
|
||||
|
||||
opts[:packages].each do |filename|
|
||||
licenses, packages = parse_package_xml(Nokogiri::XML(File.open(filename)))
|
||||
merge result[:licenses], licenses
|
||||
merge result[:packages], packages
|
||||
end
|
||||
|
||||
opts[:images].each do |filename|
|
||||
licenses, images = parse_image_xml(Nokogiri::XML(File.open(filename)))
|
||||
merge result[:licenses], licenses
|
||||
merge result[:images], images
|
||||
end
|
||||
|
||||
opts[:addons].each do |filename|
|
||||
licenses, addons, extras = parse_addon_xml(Nokogiri::XML(File.open(filename)))
|
||||
merge result[:licenses], licenses
|
||||
merge result[:addons], addons
|
||||
merge result[:extras], extras
|
||||
end
|
||||
|
||||
puts JSON.pretty_generate(fixup(result))
|
||||
19
pkgs/development/mobile/androidenv/mkrepo.sh
Executable file
19
pkgs/development/mobile/androidenv/mkrepo.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p "ruby.withPackages (pkgs: with pkgs; [ slop nokogiri ])"
|
||||
|
||||
set -e
|
||||
|
||||
pushd "$(dirname "$0")" &>/dev/null || exit 1
|
||||
|
||||
echo "Writing repo.json" >&2
|
||||
ruby mkrepo.rb \
|
||||
--packages ./xml/repository2-1.xml \
|
||||
--images ./xml/android-sys-img2-1.xml \
|
||||
--images ./xml/android-tv-sys-img2-1.xml \
|
||||
--images ./xml/android-wear-cn-sys-img2-1.xml \
|
||||
--images ./xml/android-wear-sys-img2-1.xml \
|
||||
--images ./xml/google_apis-sys-img2-1.xml \
|
||||
--images ./xml/google_apis_playstore-sys-img2-1.xml \
|
||||
--addons ./xml/addon2-1.xml > repo.json
|
||||
|
||||
popd &>/dev/null
|
||||
65
pkgs/development/mobile/androidenv/ndk-bundle/default.nix
Normal file
65
pkgs/development/mobile/androidenv/ndk-bundle/default.nix
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{ stdenv, lib, pkgs, pkgsHostHost, makeWrapper, autoPatchelfHook
|
||||
, deployAndroidPackage, package, os, platform-tools
|
||||
}:
|
||||
|
||||
let
|
||||
runtime_paths = lib.makeBinPath (with pkgsHostHost; [
|
||||
coreutils file findutils gawk gnugrep gnused jdk python3 which
|
||||
]) + ":${platform-tools}/platform-tools";
|
||||
in
|
||||
deployAndroidPackage {
|
||||
inherit package os;
|
||||
nativeBuildInputs = [ makeWrapper ]
|
||||
++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
|
||||
autoPatchelfIgnoreMissingDeps = true;
|
||||
buildInputs = lib.optional (os == "linux") [ pkgs.glibc pkgs.stdenv.cc.cc pkgs.python2 pkgs.ncurses5 pkgs.zlib pkgs.libcxx.out pkgs.libxml2 ];
|
||||
patchInstructions = lib.optionalString (os == "linux") (''
|
||||
patchShebangs .
|
||||
|
||||
# Fix the shebangs of the auto-generated scripts.
|
||||
substituteInPlace ./build/tools/make_standalone_toolchain.py \
|
||||
--replace '#!/bin/bash' '#!${pkgs.bash}/bin/bash'
|
||||
|
||||
'' + lib.optionalString (builtins.compareVersions (lib.getVersion package) "21" > 0) ''
|
||||
patch -p1 \
|
||||
--no-backup-if-mismatch < ${./make_standalone_toolchain.py_18.patch} || true
|
||||
wrapProgram ./build/tools/make_standalone_toolchain.py --prefix PATH : "${runtime_paths}"
|
||||
'' + ''
|
||||
|
||||
# TODO: allow this stuff
|
||||
rm -rf docs tests
|
||||
|
||||
# Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling
|
||||
if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then
|
||||
addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64
|
||||
fi
|
||||
|
||||
if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then
|
||||
addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64
|
||||
fi
|
||||
|
||||
find toolchains -type d -name bin -or -name lib64 | while read dir; do
|
||||
autoPatchelf "$dir"
|
||||
done
|
||||
|
||||
# fix ineffective PROGDIR / MYNDKDIR determination
|
||||
for progname in ndk-build; do
|
||||
sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname
|
||||
done
|
||||
|
||||
# Patch executables
|
||||
autoPatchelf prebuilt/linux-x86_64
|
||||
|
||||
# wrap
|
||||
for progname in ndk-build; do
|
||||
wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}"
|
||||
done
|
||||
|
||||
# make some executables available in PATH
|
||||
mkdir -p $out/bin
|
||||
for progname in ndk-build; do
|
||||
ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname
|
||||
done
|
||||
'');
|
||||
noAuditTmpdir = true; # Audit script gets invoked by the build/ component in the path for the make standalone script
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
diff -Naur android-ndk-r18b/build/tools/make_standalone_toolchain.py android-ndk-r18b-new/build/tools/make_standalone_toolchain.py
|
||||
--- android-ndk-r18b/build/tools/make_standalone_toolchain.py 2018-10-11 12:49:38.000000000 +0200
|
||||
+++ android-ndk-r18b-new/build/tools/make_standalone_toolchain.py 2018-11-20 21:55:52.689991420 +0100
|
||||
@@ -30,7 +30,7 @@
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
-
|
||||
+import subprocess
|
||||
|
||||
THIS_DIR = os.path.realpath(os.path.dirname(__file__))
|
||||
NDK_DIR = os.path.realpath(os.path.join(THIS_DIR, '../..'))
|
||||
@@ -173,6 +173,7 @@
|
||||
logger().debug('Copying %s', src_file)
|
||||
shutil.copy2(src_file, dst_dir)
|
||||
|
||||
+ subprocess.check_call(["chmod", "-R", "+w", dst])
|
||||
|
||||
def make_clang_scripts(install_dir, triple, api, windows):
|
||||
"""Creates Clang wrapper scripts.
|
||||
@@ -365,6 +366,7 @@
|
||||
install_headers = os.path.join(install_sysroot, 'usr/include')
|
||||
os.makedirs(os.path.dirname(install_headers))
|
||||
shutil.copytree(headers, install_headers)
|
||||
+ subprocess.check_call(["chmod", "-R", "+w", install_path])
|
||||
|
||||
arch_headers = os.path.join(sysroot, 'usr/include', triple)
|
||||
copy_directory_contents(arch_headers, os.path.join(install_headers))
|
||||
@@ -375,6 +377,7 @@
|
||||
install_sysroot, 'usr/lib{}'.format(lib_suffix))
|
||||
if os.path.exists(lib_path):
|
||||
shutil.copytree(lib_path, lib_install)
|
||||
+ subprocess.check_call(["chmod", "-R", "+w", install_path])
|
||||
|
||||
static_lib_path = os.path.join(sysroot, 'usr/lib', triple)
|
||||
static_lib_install = os.path.join(install_sysroot, 'usr/lib')
|
||||
@@ -389,6 +392,7 @@
|
||||
NDK_DIR, 'prebuilt', 'android-' + arch, 'gdbserver')
|
||||
gdbserver_install = os.path.join(install_path, 'share', 'gdbserver')
|
||||
shutil.copytree(gdbserver_path, gdbserver_install)
|
||||
+ subprocess.check_call(["chmod", "-R", "+w", install_path])
|
||||
|
||||
toolchain_lib_dir = os.path.join(gcc_path, 'lib/gcc', triple)
|
||||
dirs = os.listdir(toolchain_lib_dir)
|
||||
18
pkgs/development/mobile/androidenv/platform-tools.nix
Normal file
18
pkgs/development/mobile/androidenv/platform-tools.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{deployAndroidPackage, lib, package, os, autoPatchelfHook, pkgs}:
|
||||
|
||||
deployAndroidPackage {
|
||||
inherit package os;
|
||||
buildInputs = lib.optionals (os == "linux") [ autoPatchelfHook pkgs.glibc pkgs.zlib pkgs.ncurses5 ];
|
||||
patchInstructions = lib.optionalString (os == "linux") ''
|
||||
addAutoPatchelfSearchPath $packageBaseDir/lib64
|
||||
autoPatchelf --no-recurse $packageBaseDir/lib64
|
||||
autoPatchelf --no-recurse $packageBaseDir
|
||||
'' + ''
|
||||
mkdir -p $out/bin
|
||||
cd $out/bin
|
||||
find $out/libexec/android-sdk/platform-tools -type f -executable -mindepth 1 -maxdepth 1 -not -name sqlite3 | while read i
|
||||
do
|
||||
ln -s $i
|
||||
done
|
||||
'';
|
||||
}
|
||||
23
pkgs/development/mobile/androidenv/querypackages.sh
Executable file
23
pkgs/development/mobile/androidenv/querypackages.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p jq
|
||||
|
||||
set -e
|
||||
|
||||
pushd "$(dirname "$0")" &>/dev/null || exit 1
|
||||
|
||||
if [ "$1" == '' ]; then
|
||||
echo "Please select a group: 'packages', 'images', 'addons', 'extras', or 'licenses'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
namespace="$1"
|
||||
|
||||
if [ "$namespace" == 'licenses' ]; then
|
||||
jq -r '.licenses | keys | join("\n")' < repo.json
|
||||
else
|
||||
jq -r --arg NAMESPACE "$namespace" \
|
||||
'.[$NAMESPACE] | paths as $path | getpath($path) as $v | select($path[-1] == "displayName") | [[$NAMESPACE] + $path[:-1] | map("\"" + . + "\"") | join("."), $v] | join(": ")' \
|
||||
< repo.json
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
6339
pkgs/development/mobile/androidenv/repo.json
Normal file
6339
pkgs/development/mobile/androidenv/repo.json
Normal file
File diff suppressed because one or more lines are too long
26
pkgs/development/mobile/androidenv/tools.nix
Normal file
26
pkgs/development/mobile/androidenv/tools.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{deployAndroidPackage, requireFile, lib, packages, toolsVersion, autoPatchelfHook, makeWrapper, os, pkgs, pkgs_i686, postInstall ? ""}:
|
||||
|
||||
if toolsVersion == "26.0.1" then import ./tools/26.nix {
|
||||
inherit deployAndroidPackage lib autoPatchelfHook makeWrapper os pkgs pkgs_i686 postInstall;
|
||||
package = {
|
||||
name = "tools";
|
||||
path = "tools";
|
||||
revision = "26.0.1";
|
||||
archives = {
|
||||
linux = requireFile {
|
||||
url = "https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip";
|
||||
sha256 = "185yq7qwxflw24ccm5d6zziwlc9pxmsm3f54pm9p7xm0ik724kj4";
|
||||
};
|
||||
macosx = requireFile {
|
||||
url = "https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip";
|
||||
sha256 = "1ycx9gzdaqaw6n19yvxjawywacavn1jc6sadlz5qikhgfr57b0aa";
|
||||
};
|
||||
};
|
||||
};
|
||||
} else if toolsVersion == "26.1.1" then import ./tools/26.nix {
|
||||
inherit deployAndroidPackage lib autoPatchelfHook makeWrapper os pkgs pkgs_i686 postInstall;
|
||||
package = packages.tools.${toolsVersion};
|
||||
} else import ./tools/25.nix {
|
||||
inherit deployAndroidPackage lib autoPatchelfHook makeWrapper os pkgs pkgs_i686 postInstall;
|
||||
package = packages.tools.${toolsVersion};
|
||||
}
|
||||
62
pkgs/development/mobile/androidenv/tools/25.nix
Normal file
62
pkgs/development/mobile/androidenv/tools/25.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{deployAndroidPackage, lib, package, autoPatchelfHook, makeWrapper, os, pkgs, pkgs_i686, postInstall ? ""}:
|
||||
|
||||
deployAndroidPackage {
|
||||
name = "androidsdk";
|
||||
buildInputs = [ autoPatchelfHook makeWrapper ]
|
||||
++ lib.optional (os == "linux") [ pkgs.glibc pkgs.xorg.libX11 pkgs.xorg.libXext pkgs.xorg.libXdamage pkgs.xorg.libxcb pkgs.xorg.libXfixes pkgs.xorg.libXrender pkgs.fontconfig.lib pkgs.freetype pkgs.libGL pkgs.zlib pkgs.ncurses5 pkgs.libpulseaudio pkgs_i686.glibc pkgs_i686.xorg.libX11 pkgs_i686.xorg.libXrender pkgs_i686.fontconfig pkgs_i686.freetype pkgs_i686.zlib ];
|
||||
inherit package os;
|
||||
|
||||
patchInstructions = ''
|
||||
${lib.optionalString (os == "linux") ''
|
||||
# Auto patch all binaries
|
||||
addAutoPatchelfSearchPath $PWD/lib64
|
||||
addAutoPatchelfSearchPath $PWD/lib64/libstdc++
|
||||
addAutoPatchelfSearchPath $PWD/lib64/qt/lib
|
||||
addAutoPatchelfSearchPath $PWD/lib
|
||||
addAutoPatchelfSearchPath $PWD/lib/libstdc++
|
||||
autoPatchelf .
|
||||
''}
|
||||
|
||||
# Wrap all scripts that require JAVA_HOME
|
||||
for i in bin
|
||||
do
|
||||
find $i -maxdepth 1 -type f -executable | while read program
|
||||
do
|
||||
if grep -q "JAVA_HOME" $program
|
||||
then
|
||||
wrapProgram $PWD/$program --prefix PATH : ${pkgs.jdk8}/bin
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Wrap programs that require java
|
||||
for i in draw9patch jobb lint screenshot2
|
||||
do
|
||||
wrapProgram $PWD/$i \
|
||||
--prefix PATH : ${pkgs.jdk8}/bin
|
||||
done
|
||||
|
||||
# Wrap programs that require java and SWT
|
||||
for i in android ddms hierarchyviewer monitor monkeyrunner traceview uiautomatorviewer
|
||||
do
|
||||
wrapProgram $PWD/$i \
|
||||
--prefix PATH : ${pkgs.jdk8}/bin \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ pkgs.xorg.libX11 pkgs.xorg.libXtst ]}
|
||||
done
|
||||
|
||||
${lib.optionalString (os == "linux") ''
|
||||
wrapProgram $PWD/emulator \
|
||||
--prefix PATH : ${pkgs.file}/bin:${pkgs.glxinfo}/bin:${pkgs.pciutils}/bin \
|
||||
--set QT_XKB_CONFIG_ROOT ${pkgs.xkeyboard_config}/share/X11/xkb \
|
||||
--set QTCOMPOSE ${pkgs.xorg.libX11.out}/share/X11/locale
|
||||
''}
|
||||
|
||||
# Patch all script shebangs
|
||||
patchShebangs .
|
||||
|
||||
cd ..
|
||||
${postInstall}
|
||||
'';
|
||||
|
||||
meta.licenses = lib.licenses.unfree;
|
||||
}
|
||||
44
pkgs/development/mobile/androidenv/tools/26.nix
Normal file
44
pkgs/development/mobile/androidenv/tools/26.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{deployAndroidPackage, lib, package, autoPatchelfHook, makeWrapper, os, pkgs, pkgs_i686, postInstall ? ""}:
|
||||
|
||||
deployAndroidPackage {
|
||||
name = "androidsdk";
|
||||
inherit os package;
|
||||
buildInputs = [ makeWrapper ]
|
||||
++ lib.optional (os == "linux") (
|
||||
(with pkgs; [ autoPatchelfHook glibc freetype fontconfig fontconfig.lib])
|
||||
++ (with pkgs.xorg; [ libX11 libXrender libXext ])
|
||||
++ (with pkgs_i686; [ glibc xorg.libX11 xorg.libXrender xorg.libXext fontconfig.lib freetype zlib ])
|
||||
);
|
||||
|
||||
patchInstructions = ''
|
||||
${lib.optionalString (os == "linux") ''
|
||||
# Auto patch all binaries
|
||||
autoPatchelf .
|
||||
''}
|
||||
|
||||
# Wrap all scripts that require JAVA_HOME
|
||||
for i in bin
|
||||
do
|
||||
find $i -maxdepth 1 -type f -executable | while read program
|
||||
do
|
||||
if grep -q "JAVA_HOME" $program
|
||||
then
|
||||
wrapProgram $PWD/$program --prefix PATH : ${pkgs.jdk8}/bin
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Wrap monitor script
|
||||
wrapProgram $PWD/monitor \
|
||||
--prefix PATH : ${pkgs.jdk8}/bin \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ pkgs.xorg.libX11 pkgs.xorg.libXtst ]}
|
||||
|
||||
# Patch all script shebangs
|
||||
patchShebangs .
|
||||
|
||||
cd ..
|
||||
${postInstall}
|
||||
'';
|
||||
|
||||
meta.licenses = lib.licenses.unfree;
|
||||
}
|
||||
26
pkgs/development/mobile/checkra1n/default.nix
Normal file
26
pkgs/development/mobile/checkra1n/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ lib, stdenv, fetchurl }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "checkra1n";
|
||||
version = "0.12.4";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://assets.checkra.in/downloads/linux/cli/x86_64/dac9968939ea6e6bfbdedeb41d7e2579c4711dc2c5083f91dced66ca397dc51d/checkra1n";
|
||||
sha256 = "07f5glwwlrpdvj8ky265q8fp3i3r4mz1vd6yvvxnnvpa764rdjfs";
|
||||
};
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
install -dm755 "$out/bin"
|
||||
install -m755 $src $out/bin/${pname}
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Jailbreak for iPhone 5s though iPhone X, iOS 12.0 and up";
|
||||
homepage = "https://checkra.in/";
|
||||
license = licenses.unfreeRedistributable;
|
||||
maintainers = with maintainers; [ onny ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
96
pkgs/development/mobile/genymotion/default.nix
Normal file
96
pkgs/development/mobile/genymotion/default.nix
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
{ stdenv, lib, fetchurl, makeWrapper, which, zlib, libGL, glib, xorg, libxkbcommon
|
||||
, xdg-utils, libXrender, fontconfig, freetype, systemd, libpulseaudio
|
||||
# For glewinfo
|
||||
, libXmu, libXi, libXext }:
|
||||
|
||||
let
|
||||
packages = [
|
||||
stdenv.cc.cc
|
||||
zlib
|
||||
glib
|
||||
xorg.libX11
|
||||
libxkbcommon
|
||||
libXmu
|
||||
libXi
|
||||
libXext
|
||||
libGL
|
||||
libXrender
|
||||
fontconfig
|
||||
freetype
|
||||
systemd
|
||||
libpulseaudio
|
||||
];
|
||||
libPath = lib.makeLibraryPath packages;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "genymotion";
|
||||
version = "3.2.1";
|
||||
src = fetchurl {
|
||||
url = "https://dl.genymotion.com/releases/genymotion-${version}/genymotion-${version}-linux_x64.bin";
|
||||
name = "genymotion-${version}-linux_x64.bin";
|
||||
sha256 = "sha256-yCczUfiMcuu9OauMDmMdtnheDBXiC9tOEu0cWAW95FM=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ which xdg-utils ];
|
||||
|
||||
unpackPhase = ''
|
||||
mkdir -p phony-home $out/share/applications
|
||||
export HOME=$TMP/phony-home
|
||||
|
||||
mkdir ${pname}
|
||||
echo "y" | sh $src -d ${pname}
|
||||
sourceRoot=${pname}
|
||||
|
||||
substitute phony-home/.local/share/applications/genymobile-genymotion.desktop \
|
||||
$out/share/applications/genymobile-genymotion.desktop --replace "$TMP/${pname}" "$out/libexec"
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/libexec
|
||||
mv genymotion $out/libexec/
|
||||
ln -s $out/libexec/genymotion/{genymotion,player} $out/bin
|
||||
'';
|
||||
|
||||
fixupPhase = ''
|
||||
patchInterpreter() {
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
"$out/libexec/genymotion/$1"
|
||||
}
|
||||
|
||||
patchExecutable() {
|
||||
patchInterpreter "$1"
|
||||
wrapProgram "$out/libexec/genymotion/$1" \
|
||||
--set "LD_LIBRARY_PATH" "${libPath}" \
|
||||
--unset "QML2_IMPORT_PATH"
|
||||
}
|
||||
|
||||
patchTool() {
|
||||
patchInterpreter "tools/$1"
|
||||
wrapProgram "$out/libexec/genymotion/tools/$1" \
|
||||
--set "LD_LIBRARY_PATH" "${libPath}"
|
||||
}
|
||||
|
||||
patchExecutable genymotion
|
||||
patchExecutable player
|
||||
|
||||
patchTool adb
|
||||
patchTool aapt
|
||||
patchTool glewinfo
|
||||
|
||||
rm $out/libexec/genymotion/libxkbcommon*
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Fast and easy Android emulation";
|
||||
longDescription = ''
|
||||
Genymotion is a relatively fast Android emulator which comes with
|
||||
pre-configured Android (x86 with OpenGL hardware acceleration) images,
|
||||
suitable for application testing.
|
||||
'';
|
||||
homepage = "https://www.genymotion.com/";
|
||||
license = licenses.unfree;
|
||||
platforms = ["x86_64-linux"];
|
||||
maintainers = [ maintainers.puffnfresh ];
|
||||
};
|
||||
}
|
||||
61
pkgs/development/mobile/gomobile/default.nix
Normal file
61
pkgs/development/mobile/gomobile/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{ stdenv, lib, fetchgit, buildGoModule, zlib, makeWrapper, xcodeenv, androidenv
|
||||
, xcodeWrapperArgs ? { }
|
||||
, xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs
|
||||
, withAndroidPkgs ? true
|
||||
, androidPkgs ? androidenv.composeAndroidPackages {
|
||||
includeNDK = true;
|
||||
ndkVersion = "22.1.7171670";
|
||||
} }:
|
||||
|
||||
buildGoModule {
|
||||
pname = "gomobile";
|
||||
version = "unstable-2021-06-14";
|
||||
|
||||
vendorSha256 = "1irgkgv72rakg7snk1bnp10ibr64ykz9l40s59l4fnl63zsh12a0";
|
||||
|
||||
src = fetchgit {
|
||||
rev = "7c8f154d100840bc5828285bb390bbae1cb5a98c";
|
||||
name = "gomobile";
|
||||
url = "https://go.googlesource.com/mobile";
|
||||
sha256 = "1w9mra1mqf60iafp0ywvja5196fjsjyfhvz4yizqq4qkyll5qmj1";
|
||||
};
|
||||
|
||||
subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
|
||||
|
||||
# Fails with: go: cannot find GOROOT directory
|
||||
doCheck = false;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ]
|
||||
++ lib.optionals stdenv.isDarwin [ xcodeWrapper ];
|
||||
|
||||
# Prevent a non-deterministic temporary directory from polluting the resulting object files
|
||||
postPatch = ''
|
||||
substituteInPlace cmd/gomobile/env.go --replace \
|
||||
'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
|
||||
'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")' \
|
||||
--replace '"io/ioutil"' ""
|
||||
substituteInPlace cmd/gomobile/init.go --replace \
|
||||
'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
|
||||
'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "work")'
|
||||
'';
|
||||
|
||||
# Necessary for GOPATH when using gomobile.
|
||||
postInstall = ''
|
||||
mkdir -p $out/src/golang.org/x
|
||||
ln -s $src $out/src/golang.org/x/mobile
|
||||
wrapProgram $out/bin/gomobile \
|
||||
'' + lib.optionalString withAndroidPkgs ''
|
||||
--prefix PATH : "${androidPkgs.androidsdk}/bin" \
|
||||
--set ANDROID_NDK_HOME "${androidPkgs.androidsdk}/libexec/android-sdk/ndk-bundle" \
|
||||
--set ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" \
|
||||
'' + ''
|
||||
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A tool for building and running mobile apps written in Go";
|
||||
homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile";
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ jakubgs ];
|
||||
};
|
||||
}
|
||||
32
pkgs/development/mobile/imgpatchtools/default.nix
Normal file
32
pkgs/development/mobile/imgpatchtools/default.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ lib, stdenv, fetchFromGitHub, bzip2, openssl, zlib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "imgpatchtools";
|
||||
version = "0.3";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "erfanoabdi";
|
||||
repo = "imgpatchtools";
|
||||
rev = version;
|
||||
sha256 = "sha256-7TOkqaXPui14VcSmMmYJ1Wg+s85wrgp+E0XcCB0Ml7M=";
|
||||
};
|
||||
|
||||
buildInputs = [ bzip2 openssl zlib ];
|
||||
|
||||
installPhase = "install -Dt $out/bin bin/*";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Tools to manipulate Android OTA archives";
|
||||
longDescription = ''
|
||||
This package is useful for Android development. In particular, it can be
|
||||
used to extract ext4 /system image from Android distribution ZIP archives
|
||||
such as those distributed by LineageOS and Replicant, via BlockImageUpdate
|
||||
utility. It also includes other, related, but arguably more advanced tools
|
||||
for OTA manipulation.
|
||||
'';
|
||||
homepage = "https://github.com/erfanoabdi/imgpatchtools";
|
||||
license = licenses.gpl3;
|
||||
maintainers = with maintainers; [ yana ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
188
pkgs/development/mobile/titaniumenv/build-app.nix
Normal file
188
pkgs/development/mobile/titaniumenv/build-app.nix
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
{stdenv, lib, composeAndroidPackages, composeXcodeWrapper, titaniumsdk, titanium, alloy, jdk, python, nodejs, which, file}:
|
||||
{ name, src, preBuild ? "", target, tiVersion ? null
|
||||
, release ? false, androidKeyStore ? null, androidKeyAlias ? null, androidKeyStorePassword ? null
|
||||
, iosMobileProvisioningProfile ? null, iosCertificateName ? null, iosCertificate ? null, iosCertificatePassword ? null, iosVersion ? "12.1", iosBuildStore ? false
|
||||
, enableWirelessDistribution ? false, installURL ? null
|
||||
, xcodeBaseDir ? "/Applications/Xcode.app"
|
||||
, androidsdkArgs ? {}
|
||||
, xcodewrapperArgs ? {}
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert (release && target == "android") -> androidKeyStore != null && androidKeyAlias != null && androidKeyStorePassword != null;
|
||||
assert (release && target == "iphone") -> iosMobileProvisioningProfile != null && iosCertificateName != null && iosCertificate != null && iosCertificatePassword != null;
|
||||
assert enableWirelessDistribution -> installURL != null;
|
||||
|
||||
let
|
||||
realAndroidsdkArgs = {
|
||||
platformVersions = [ "28" ];
|
||||
} // androidsdkArgs;
|
||||
|
||||
androidsdk = (composeAndroidPackages realAndroidsdkArgs).androidsdk;
|
||||
|
||||
xcodewrapper = composeXcodeWrapper xcodewrapperArgs;
|
||||
|
||||
deleteKeychain = ''
|
||||
if [ -f $HOME/lock-keychain ]
|
||||
then
|
||||
security default-keychain -s login.keychain
|
||||
security delete-keychain $keychainName
|
||||
rm -f $HOME/lock-keychain
|
||||
fi
|
||||
'';
|
||||
|
||||
extraArgs = removeAttrs args [ "name" "preRebuild" "androidsdkArgs" "xcodewrapperArgs" ];
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
name = lib.replaceChars [" "] [""] name;
|
||||
|
||||
buildInputs = [ nodejs titanium alloy python which file jdk ];
|
||||
|
||||
buildPhase = ''
|
||||
${preBuild}
|
||||
|
||||
${lib.optionalString stdenv.isDarwin ''
|
||||
# Hack that provides a writable alloy package on macOS. Without it the build fails because of a file permission error.
|
||||
alloy=$(dirname $(type -p alloy))/..
|
||||
cp -rv $alloy/* alloy
|
||||
chmod -R u+w alloy
|
||||
export PATH=$(pwd)/alloy/bin:$PATH
|
||||
''}
|
||||
|
||||
export HOME=${if target == "iphone" then "/Users/$(whoami)" else "$TMPDIR"}
|
||||
|
||||
${lib.optionalString (tiVersion != null) ''
|
||||
# Replace titanium version by the provided one
|
||||
sed -i -e "s|<sdk-version>[0-9a-zA-Z\.]*</sdk-version>|<sdk-version>${tiVersion}</sdk-version>|" tiapp.xml
|
||||
''}
|
||||
|
||||
# Simulate a login
|
||||
mkdir -p $HOME/.titanium
|
||||
cat > $HOME/.titanium/auth_session.json <<EOF
|
||||
{ "loggedIn": true }
|
||||
EOF
|
||||
|
||||
# Configure the paths to the Titanium SDK and modules
|
||||
echo "{}" > $TMPDIR/config.json
|
||||
titanium --config-file $TMPDIR/config.json --no-colors config sdk.defaultInstallLocation ${titaniumsdk}
|
||||
titanium --config-file $TMPDIR/config.json --no-colors config paths.modules ${titaniumsdk}
|
||||
|
||||
mkdir -p $out
|
||||
|
||||
${if target == "android" then ''
|
||||
titanium config --config-file $TMPDIR/config.json --no-colors android.sdkPath ${androidsdk}/libexec/android-sdk
|
||||
|
||||
export PATH=${androidsdk}/libexec/android-sdk/tools:$(echo ${androidsdk}/libexec/android-sdk/build-tools/android-*):$PATH
|
||||
export GRADLE_USER_HOME=$TMPDIR/gradle
|
||||
|
||||
${if release then ''
|
||||
${lib.optionalString stdenv.isDarwin ''
|
||||
# Signing the app does not work with OpenJDK on macOS, use host SDK instead
|
||||
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
|
||||
''}
|
||||
titanium build --config-file $TMPDIR/config.json --no-colors --force --platform android --target dist-playstore --keystore ${androidKeyStore} --alias "${androidKeyAlias}" --store-password "${androidKeyStorePassword}" --output-dir $out
|
||||
'' else ''
|
||||
titanium build --config-file $TMPDIR/config.json --no-colors --force --platform android --target emulator --build-only -B foo --output $out
|
||||
''}
|
||||
''
|
||||
else if target == "iphone" then ''
|
||||
# Be sure that the Xcode wrapper has priority over everything else.
|
||||
# When using buildInputs this does not seem to be the case.
|
||||
export PATH=${xcodewrapper}/bin:$PATH
|
||||
|
||||
# Configure the path to Xcode
|
||||
titanium --config-file $TMPDIR/config.json --no-colors config paths.xcode ${xcodeBaseDir}
|
||||
|
||||
# Link the modules folder
|
||||
if [ ! -e modules ]
|
||||
then
|
||||
ln -s ${titaniumsdk}/modules modules
|
||||
createdModulesSymlink=1
|
||||
fi
|
||||
|
||||
${if release then ''
|
||||
# Create a keychain with the component hash name (should always be unique)
|
||||
export keychainName=$(basename $out)
|
||||
|
||||
security create-keychain -p "" $keychainName
|
||||
security default-keychain -s $keychainName
|
||||
security unlock-keychain -p "" $keychainName
|
||||
security import ${iosCertificate} -k $keychainName -P "${iosCertificatePassword}" -A
|
||||
security set-key-partition-list -S apple-tool:,apple: -s -k "" $keychainName
|
||||
provisioningId=$(grep UUID -A1 -a ${iosMobileProvisioningProfile} | grep -o "[-A-Za-z0-9]\{36\}")
|
||||
|
||||
# Ensure that the requested provisioning profile can be found
|
||||
|
||||
if [ ! -f "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" ]
|
||||
then
|
||||
mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
|
||||
cp ${iosMobileProvisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision"
|
||||
fi
|
||||
|
||||
# Take precautions to prevent concurrent builds blocking the keychain
|
||||
while [ -f $HOME/lock-keychain ]
|
||||
do
|
||||
echo "Keychain locked, waiting for a couple of seconds, or remove $HOME/lock-keychain to unblock..."
|
||||
sleep 3
|
||||
done
|
||||
|
||||
touch $HOME/lock-keychain
|
||||
|
||||
security default-keychain -s $keychainName
|
||||
|
||||
# Do the actual build
|
||||
titanium build --config-file $TMPDIR/config.json --force --no-colors --platform ios --target ${if iosBuildStore then "dist-appstore" else "dist-adhoc"} --pp-uuid $provisioningId --distribution-name "${iosCertificateName}" --keychain $HOME/Library/Keychains/$keychainName-db --device-family universal --ios-version ${iosVersion} --output-dir $out
|
||||
|
||||
# Remove our generated keychain
|
||||
${deleteKeychain}
|
||||
'' else ''
|
||||
# Copy all sources to the output store directory.
|
||||
# Why? Debug application include *.js files, which are symlinked into their
|
||||
# sources. If they are not copied, we have dangling references to the
|
||||
# temp folder.
|
||||
|
||||
cp -av * $out
|
||||
cd $out
|
||||
|
||||
# Execute the build
|
||||
titanium build --config-file $TMPDIR/config.json --force --no-colors --platform ios --target simulator --build-only --device-family universal --ios-version ${iosVersion} --output-dir $out
|
||||
|
||||
# Remove the modules symlink
|
||||
if [ "$createdModulesSymlink" = "1" ]
|
||||
then
|
||||
rm $out/modules
|
||||
fi
|
||||
''}
|
||||
'' else throw "Target: ${target} is not supported!"}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
${if target == "android" then ''
|
||||
${if release then ""
|
||||
else ''
|
||||
cp "$(ls build/android/bin/*.apk | grep -v '\-unsigned.apk')" $out
|
||||
''}
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist \"$(ls $out/*.apk)\"" > $out/nix-support/hydra-build-products
|
||||
''
|
||||
else if target == "iphone" then
|
||||
if release then ''
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist \"$(echo $out/*.ipa)\"" > $out/nix-support/hydra-build-products
|
||||
|
||||
${lib.optionalString enableWirelessDistribution ''
|
||||
appname="$(basename $out/*.ipa .ipa)"
|
||||
bundleId=$(grep '<id>[a-zA-Z0-9.]*</id>' tiapp.xml | sed -e 's|<id>||' -e 's|</id>||' -e 's/ //g')
|
||||
version=$(grep '<version>[a-zA-Z0-9.]*</version>' tiapp.xml | sed -e 's|<version>||' -e 's|</version>||' -e 's/ //g')
|
||||
|
||||
sed -e "s|@INSTALL_URL@|${installURL}?bundleId=$bundleId\&version=$version\&title=$appname|" ${../xcodeenv/install.html.template} > "$out/$appname.html"
|
||||
echo "doc install \"$out/$appname.html\"" >> $out/nix-support/hydra-build-products
|
||||
''}
|
||||
''
|
||||
else ""
|
||||
else throw "Target: ${target} is not supported!"}
|
||||
'';
|
||||
|
||||
failureHook = lib.optionalString (release && target == "iphone") deleteKeychain;
|
||||
} // extraArgs)
|
||||
21
pkgs/development/mobile/titaniumenv/default.nix
Normal file
21
pkgs/development/mobile/titaniumenv/default.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{pkgs, androidenv, xcodeenv, tiVersion ? "8.3.2.GA"}:
|
||||
|
||||
rec {
|
||||
titaniumsdk = let
|
||||
titaniumSdkFile = if tiVersion == "8.2.1.GA" then ./titaniumsdk-8.2.nix
|
||||
else if tiVersion == "7.5.1.GA" then ./titaniumsdk-7.5.nix
|
||||
else if tiVersion == "8.3.2.GA" then ./titaniumsdk-8.3.nix
|
||||
else throw "Titanium version not supported: "+tiVersion;
|
||||
in
|
||||
import titaniumSdkFile {
|
||||
inherit (pkgs) stdenv lib fetchurl unzip makeWrapper;
|
||||
};
|
||||
|
||||
buildApp = import ./build-app.nix {
|
||||
inherit (pkgs) stdenv lib python which file jdk nodejs;
|
||||
inherit (pkgs.nodePackages) alloy titanium;
|
||||
inherit (androidenv) composeAndroidPackages;
|
||||
inherit (xcodeenv) composeXcodeWrapper;
|
||||
inherit titaniumsdk;
|
||||
};
|
||||
}
|
||||
112
pkgs/development/mobile/titaniumenv/titaniumsdk-7.5.nix
Normal file
112
pkgs/development/mobile/titaniumenv/titaniumsdk-7.5.nix
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
{ stdenv, fetchurl, unzip, makeWrapper }:
|
||||
|
||||
let
|
||||
# Gradle is a build system that bootstraps itself. This is what it actually
|
||||
# downloads in the bootstrap phase.
|
||||
gradleAllZip = fetchurl {
|
||||
url = "http://services.gradle.org/distributions/gradle-4.1-all.zip";
|
||||
sha256 = "1rcrh263vq7a0is800y5z36jj97p67c6zpqzzfcbr7r0qaxb61sw";
|
||||
};
|
||||
|
||||
# A Titanium-Android build requires proguard plugins. We create a fake
|
||||
# repository so that Gradle does not attempt to download them in the builder.
|
||||
# Since there are only 3 plugins required, this is still (sort of) manageable
|
||||
# without a generator.
|
||||
proguardVersion = "5.3.3";
|
||||
|
||||
proguardGradlePOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.pom";
|
||||
sha256 = "03v9zm3ykfkyb5cs5ald07ph103fh68d5c33rv070r29p71dwszj";
|
||||
};
|
||||
proguardGradleJAR = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.jar";
|
||||
sha256 = "0shhpsjfc5gam15jnv1hk718v5c7vi7dwdc3gvmnid6dc85kljzk";
|
||||
};
|
||||
proguardParentPOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-parent/${proguardVersion}/proguard-parent-${proguardVersion}.pom";
|
||||
sha256 = "0mv0zbwyw8xa4mkc5kw69y5xqashkz9gp123akfvh9f6152l3202";
|
||||
};
|
||||
proguardBasePOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.pom";
|
||||
sha256 = "1jnr6zsxfimb8wglqlwa6rrdc3g3nqf1dyw0k2dq9cj0q4pgn7p5";
|
||||
};
|
||||
proguardBaseJAR = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.jar";
|
||||
sha256 = "11nwdb9y84cghcx319nsjjf9m035s4s1184zrhzpvaxq2wvqhbhx";
|
||||
};
|
||||
|
||||
# Put the downloaded plugins in a fake Maven repository
|
||||
fakeMavenRepo = stdenv.mkDerivation {
|
||||
name = "fake-maven-repo";
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cd $out
|
||||
mkdir -p net/sf/proguard/proguard-gradle/${proguardVersion}
|
||||
cp ${proguardGradlePOM} net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.pom
|
||||
cp ${proguardGradleJAR} net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.jar
|
||||
mkdir -p net/sf/proguard/proguard-parent/${proguardVersion}
|
||||
cp ${proguardParentPOM} net/sf/proguard/proguard-parent/${proguardVersion}/proguard-parent-${proguardVersion}.pom
|
||||
mkdir -p net/sf/proguard/proguard-base/${proguardVersion}
|
||||
cp ${proguardBasePOM} net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.pom
|
||||
cp ${proguardBaseJAR} net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.jar
|
||||
'';
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "mobilesdk";
|
||||
version = "7.5.1.GA";
|
||||
|
||||
src =
|
||||
if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") then
|
||||
fetchurl {
|
||||
url = "https://builds.appcelerator.com/mobile/7_5_X/mobilesdk-7.5.1.v20190124152315-linux.zip";
|
||||
sha256 = "1ihyh6szl9a2gbdgv13msd3g7i3xi9ifmgsh6v562hqlfi4lixng";
|
||||
}
|
||||
else if stdenv.system == "x86_64-darwin" then
|
||||
fetchurl {
|
||||
url = "https://builds.appcelerator.com/mobile/7_5_X/mobilesdk-7.5.1.v20190124152315-osx.zip";
|
||||
sha256 = "1whs1j7fkk2hxr4nxq50d7ic5wj83b1i1jl0p722sqbvkmgxssa2";
|
||||
}
|
||||
else throw "Platform: ${stdenv.system} not supported!";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cd $out
|
||||
(yes y | unzip $src) || true
|
||||
|
||||
# Rename ugly version number
|
||||
cd mobilesdk/*
|
||||
mv * 7.5.1.GA
|
||||
cd *
|
||||
|
||||
# Patch bundled gradle build infrastructure to make shebangs work
|
||||
patchShebangs android/templates/gradle
|
||||
|
||||
# Substitute the gradle-all zip URL by a local file to prevent downloads from happening while building an Android app
|
||||
sed -i -e "s|distributionUrl=|#distributionUrl=|" android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
|
||||
cp ${gradleAllZip} android/templates/gradle/gradle/wrapper/gradle-4.1-all.zip
|
||||
echo "distributionUrl=gradle-4.1-all.zip" >> android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
# Patch maven central repository with our own local directory. This prevents the builder from downloading Maven artifacts
|
||||
sed -i -e 's|mavenCentral()|maven { url "${fakeMavenRepo}" }|' android/templates/build/proguard.gradle
|
||||
|
||||
# Patch the strip frameworks script in the iPhone build template to not let
|
||||
# it skip the strip phase. This is caused by an assumption on the file
|
||||
# permissions in which Nix deviates from the standard.
|
||||
sed -i -e "s|-perm +111|-perm /111|" iphone/templates/build/strip-frameworks.sh
|
||||
|
||||
# Patch some executables
|
||||
|
||||
${if stdenv.system == "i686-linux" then
|
||||
''
|
||||
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 android/titanium_prep.linux32
|
||||
''
|
||||
else if stdenv.system == "x86_64-linux" then
|
||||
''
|
||||
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 android/titanium_prep.linux64
|
||||
''
|
||||
else ""}
|
||||
'';
|
||||
}
|
||||
114
pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix
Normal file
114
pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
{ stdenv, lib, fetchurl, unzip, makeWrapper }:
|
||||
|
||||
let
|
||||
# Gradle is a build system that bootstraps itself. This is what it actually
|
||||
# downloads in the bootstrap phase.
|
||||
gradleAllZip = fetchurl {
|
||||
url = "http://services.gradle.org/distributions/gradle-4.1-all.zip";
|
||||
sha256 = "1rcrh263vq7a0is800y5z36jj97p67c6zpqzzfcbr7r0qaxb61sw";
|
||||
};
|
||||
|
||||
# A Titanium-Android build requires proguard plugins. We create a fake
|
||||
# repository so that Gradle does not attempt to download them in the builder.
|
||||
# Since there are only 3 plugins required, this is still (sort of) manageable
|
||||
# without a generator.
|
||||
proguardVersion = "5.3.3";
|
||||
|
||||
proguardGradlePOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.pom";
|
||||
sha256 = "03v9zm3ykfkyb5cs5ald07ph103fh68d5c33rv070r29p71dwszj";
|
||||
};
|
||||
proguardGradleJAR = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.jar";
|
||||
sha256 = "0shhpsjfc5gam15jnv1hk718v5c7vi7dwdc3gvmnid6dc85kljzk";
|
||||
};
|
||||
proguardParentPOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-parent/${proguardVersion}/proguard-parent-${proguardVersion}.pom";
|
||||
sha256 = "0mv0zbwyw8xa4mkc5kw69y5xqashkz9gp123akfvh9f6152l3202";
|
||||
};
|
||||
proguardBasePOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.pom";
|
||||
sha256 = "1jnr6zsxfimb8wglqlwa6rrdc3g3nqf1dyw0k2dq9cj0q4pgn7p5";
|
||||
};
|
||||
proguardBaseJAR = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.jar";
|
||||
sha256 = "11nwdb9y84cghcx319nsjjf9m035s4s1184zrhzpvaxq2wvqhbhx";
|
||||
};
|
||||
|
||||
# Put the downloaded plugins in a fake Maven repository
|
||||
fakeMavenRepo = stdenv.mkDerivation {
|
||||
name = "fake-maven-repo";
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cd $out
|
||||
mkdir -p net/sf/proguard/proguard-gradle/${proguardVersion}
|
||||
cp ${proguardGradlePOM} net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.pom
|
||||
cp ${proguardGradleJAR} net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.jar
|
||||
mkdir -p net/sf/proguard/proguard-parent/${proguardVersion}
|
||||
cp ${proguardParentPOM} net/sf/proguard/proguard-parent/${proguardVersion}/proguard-parent-${proguardVersion}.pom
|
||||
mkdir -p net/sf/proguard/proguard-base/${proguardVersion}
|
||||
cp ${proguardBasePOM} net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.pom
|
||||
cp ${proguardBaseJAR} net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.jar
|
||||
'';
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "mobilesdk";
|
||||
version = "8.2.1.GA";
|
||||
|
||||
src =
|
||||
if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") then
|
||||
fetchurl {
|
||||
url = "https://builds.appcelerator.com/mobile/8_2_X/mobilesdk-8.2.1.v20191025070136-linux.zip";
|
||||
sha256 = "1nvcmm6cby6bmwdiacq46n5y4zjpz9qlipakvglw27j3p4rbmkwl";
|
||||
}
|
||||
else if stdenv.system == "x86_64-darwin" then
|
||||
fetchurl {
|
||||
url = "https://builds.appcelerator.com/mobile/8_2_X/mobilesdk-8.2.1.v20191025070136-osx.zip";
|
||||
sha256 = "1nxwmyw3vqc5wghj38kpksisy0i808x0x3pa8w3p290w709g311l";
|
||||
}
|
||||
else throw "Platform: ${stdenv.system} not supported!";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cd $out
|
||||
(yes y | unzip $src) || true
|
||||
|
||||
# Rename ugly version number
|
||||
cd mobilesdk/*
|
||||
mv * 8.2.1.GA
|
||||
cd *
|
||||
|
||||
# Patch bundled gradle build infrastructure to make shebangs work
|
||||
patchShebangs android/templates/gradle
|
||||
|
||||
# Substitute the gradle-all zip URL by a local file to prevent downloads from happening while building an Android app
|
||||
sed -i -e "s|distributionUrl=|#distributionUrl=|" android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
|
||||
cp ${gradleAllZip} android/templates/gradle/gradle/wrapper/gradle-4.1-all.zip
|
||||
echo "distributionUrl=gradle-4.1-all.zip" >> android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
# Patch maven central repository with our own local directory. This prevents the builder from downloading Maven artifacts
|
||||
sed -i -e 's|mavenCentral()|maven { url "${fakeMavenRepo}" }|' android/templates/build/proguard.gradle
|
||||
|
||||
${lib.optionalString (stdenv.system == "x86_64-darwin") ''
|
||||
# Patch the strip frameworks script in the iPhone build template to not let
|
||||
# it skip the strip phase. This is caused by an assumption on the file
|
||||
# permissions in which Nix deviates from the standard.
|
||||
sed -i -e "s|-perm +111|-perm /111|" iphone/templates/build/strip-frameworks.sh
|
||||
''}
|
||||
|
||||
# Patch some executables
|
||||
|
||||
${if stdenv.system == "i686-linux" then
|
||||
''
|
||||
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 android/titanium_prep.linux32
|
||||
''
|
||||
else if stdenv.system == "x86_64-linux" then
|
||||
''
|
||||
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 android/titanium_prep.linux64
|
||||
''
|
||||
else ""}
|
||||
'';
|
||||
}
|
||||
102
pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix
Normal file
102
pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{ stdenv, lib, fetchurl, unzip, makeWrapper }:
|
||||
|
||||
let
|
||||
# Gradle is a build system that bootstraps itself. This is what it actually
|
||||
# downloads in the bootstrap phase.
|
||||
gradleAllZip = fetchurl {
|
||||
url = "http://services.gradle.org/distributions/gradle-4.1-all.zip";
|
||||
sha256 = "1rcrh263vq7a0is800y5z36jj97p67c6zpqzzfcbr7r0qaxb61sw";
|
||||
};
|
||||
|
||||
# A Titanium-Android build requires proguard plugins. We create a fake
|
||||
# repository so that Gradle does not attempt to download them in the builder.
|
||||
# Since there are only 3 plugins required, this is still (sort of) manageable
|
||||
# without a generator.
|
||||
proguardVersion = "5.3.3";
|
||||
|
||||
proguardGradlePOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.pom";
|
||||
sha256 = "03v9zm3ykfkyb5cs5ald07ph103fh68d5c33rv070r29p71dwszj";
|
||||
};
|
||||
proguardGradleJAR = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.jar";
|
||||
sha256 = "0shhpsjfc5gam15jnv1hk718v5c7vi7dwdc3gvmnid6dc85kljzk";
|
||||
};
|
||||
proguardParentPOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-parent/${proguardVersion}/proguard-parent-${proguardVersion}.pom";
|
||||
sha256 = "0mv0zbwyw8xa4mkc5kw69y5xqashkz9gp123akfvh9f6152l3202";
|
||||
};
|
||||
proguardBasePOM = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.pom";
|
||||
sha256 = "1jnr6zsxfimb8wglqlwa6rrdc3g3nqf1dyw0k2dq9cj0q4pgn7p5";
|
||||
};
|
||||
proguardBaseJAR = fetchurl {
|
||||
url = "mirror://maven/net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.jar";
|
||||
sha256 = "11nwdb9y84cghcx319nsjjf9m035s4s1184zrhzpvaxq2wvqhbhx";
|
||||
};
|
||||
|
||||
# Put the downloaded plugins in a fake Maven repository
|
||||
fakeMavenRepo = stdenv.mkDerivation {
|
||||
name = "fake-maven-repo";
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cd $out
|
||||
mkdir -p net/sf/proguard/proguard-gradle/${proguardVersion}
|
||||
cp ${proguardGradlePOM} net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.pom
|
||||
cp ${proguardGradleJAR} net/sf/proguard/proguard-gradle/${proguardVersion}/proguard-gradle-${proguardVersion}.jar
|
||||
mkdir -p net/sf/proguard/proguard-parent/${proguardVersion}
|
||||
cp ${proguardParentPOM} net/sf/proguard/proguard-parent/${proguardVersion}/proguard-parent-${proguardVersion}.pom
|
||||
mkdir -p net/sf/proguard/proguard-base/${proguardVersion}
|
||||
cp ${proguardBasePOM} net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.pom
|
||||
cp ${proguardBaseJAR} net/sf/proguard/proguard-base/${proguardVersion}/proguard-base-${proguardVersion}.jar
|
||||
'';
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "mobilesdk";
|
||||
version = "8.3.2.GA";
|
||||
|
||||
src =
|
||||
if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") then
|
||||
fetchurl {
|
||||
url = "https://builds.appcelerator.com/mobile/8_3_X/mobilesdk-8.3.2.v20200117111803-linux.zip";
|
||||
sha256 = "04pfw21jrx9w259lphynwykqjk4c9hm0zix4d40s7mf8mmh3xdx9";
|
||||
}
|
||||
else if stdenv.system == "x86_64-darwin" then
|
||||
fetchurl {
|
||||
url = "https://builds.appcelerator.com/mobile/8_3_X/mobilesdk-8.3.2.v20200117111803-osx.zip";
|
||||
sha256 = "1zflq5hc96lrriw71ya623kkskkisi9yayg8qs03zimi0gksizxw";
|
||||
}
|
||||
else throw "Platform: ${stdenv.system} not supported!";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cd $out
|
||||
unzip $src
|
||||
|
||||
# Rename ugly version number
|
||||
cd mobilesdk/*
|
||||
mv * 8.3.2.GA
|
||||
cd *
|
||||
|
||||
# Patch bundled gradle build infrastructure to make shebangs work
|
||||
patchShebangs android/templates/gradle
|
||||
|
||||
# Substitute the gradle-all zip URL by a local file to prevent downloads from happening while building an Android app
|
||||
sed -i -e "s|distributionUrl=|#distributionUrl=|" android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
|
||||
cp ${gradleAllZip} android/templates/gradle/gradle/wrapper/gradle-4.1-all.zip
|
||||
echo "distributionUrl=gradle-4.1-all.zip" >> android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
# Patch maven central repository with our own local directory. This prevents the builder from downloading Maven artifacts
|
||||
sed -i -e 's|mavenCentral()|maven { url "${fakeMavenRepo}" }|' android/templates/build/proguard.gradle
|
||||
|
||||
${lib.optionalString (stdenv.system == "x86_64-darwin") ''
|
||||
# Patch the strip frameworks script in the iPhone build template to not let
|
||||
# it skip the strip phase. This is caused by an assumption on the file
|
||||
# permissions in which Nix deviates from the standard.
|
||||
sed -i -e "s|-perm +111|-perm /111|" iphone/templates/build/strip-frameworks.sh
|
||||
''}
|
||||
'';
|
||||
}
|
||||
32
pkgs/development/mobile/webos/cmake-modules.nix
Normal file
32
pkgs/development/mobile/webos/cmake-modules.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ lib, stdenv, fetchFromGitHub, cmake }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "cmake-modules-webos";
|
||||
version = "19";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "openwebos";
|
||||
repo = "cmake-modules-webos";
|
||||
rev = "submissions/${version}";
|
||||
sha256 = "1l4hpcmgc98kp9g1642sy111ki5qyk3q7j10xzkgmnvz8lqffnxp";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
prePatch = ''
|
||||
substituteInPlace CMakeLists.txt --replace "CMAKE_ROOT}/Modules" "CMAKE_INSTALL_PREFIX}/lib/cmake"
|
||||
substituteInPlace webOS/webOS.cmake \
|
||||
--replace ' ''${CMAKE_ROOT}/Modules' " $out/lib/cmake" \
|
||||
--replace 'INSTALL_ROOT}/usr' 'INSTALL_ROOT}'
|
||||
|
||||
sed -i '/CMAKE_INSTALL_PREFIX/d' webOS/webOS.cmake
|
||||
'';
|
||||
|
||||
setupHook = ./cmake-setup-hook.sh;
|
||||
|
||||
meta = with lib; {
|
||||
description = "CMake modules needed to build Open WebOS components";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ dtzWill ];
|
||||
};
|
||||
}
|
||||
9
pkgs/development/mobile/webos/cmake-setup-hook.sh
Normal file
9
pkgs/development/mobile/webos/cmake-setup-hook.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
_addWebOSCMakeFlags() {
|
||||
# Help find the webOS cmake module
|
||||
cmakeFlagsArray+=(-DCMAKE_MODULE_PATH=@out@/lib/cmake)
|
||||
|
||||
# fix installation path (doesn't use CMAKE_INSTALL_PREFIX)
|
||||
cmakeFlagsArray+=(-DWEBOS_INSTALL_ROOT=${!outputBin})
|
||||
}
|
||||
|
||||
preConfigureHooks+=(_addWebOSCMakeFlags)
|
||||
27
pkgs/development/mobile/webos/novacom.nix
Normal file
27
pkgs/development/mobile/webos/novacom.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{ lib, stdenv, fetchFromGitHub, webos, cmake, pkg-config }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "novacom";
|
||||
version = "18";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "openwebos";
|
||||
repo = "novacom";
|
||||
rev = "submissions/${version}";
|
||||
sha256 = "12s6g7l20kakyjlhqpli496miv2kfsdp17lcwhdrzdxvxl6hnf4n";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake pkg-config webos.cmake-modules ];
|
||||
|
||||
postInstall = ''
|
||||
install -Dm755 -t $out/bin ../scripts/novaterm
|
||||
substituteInPlace $out/bin/novaterm --replace "exec novacom" "exec $out/bin/novacom"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Utility for communicating with WebOS devices";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ dtzWill ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
45
pkgs/development/mobile/webos/novacomd.nix
Normal file
45
pkgs/development/mobile/webos/novacomd.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{ lib, stdenv,
|
||||
fetchFromGitHub, fetchpatch,
|
||||
webos, cmake, pkg-config,
|
||||
libusb-compat-0_1 }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "novacomd";
|
||||
version = "127";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "openwebos";
|
||||
repo = "novacomd";
|
||||
rev = "submissions/${version}";
|
||||
sha256 = "1gahc8bvvvs4d6svrsw24iw5r0mhy4a2ars3j2gz6mp6sh42bznl";
|
||||
};
|
||||
|
||||
patches = [
|
||||
(fetchpatch {
|
||||
url = "https://aur.archlinux.org/cgit/aur.git/plain/0001-Use-usb_bulk_-read-write-instead-of-homemade-handler.patch?h=palm-novacom-git";
|
||||
sha256 = "116r6p4l767fqxfvq03sy6v7vxja8pkxlrc5hqby351a40b5dkiv";
|
||||
})
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/feniksa/webos-overlay/40e2c113fc9426d50bdf37779da57ce4ff06ee6e/net-misc/novacomd/files/0011-Remove-verbose-output.patch";
|
||||
sha256 = "09lmv06ziwkfg19b1h3jsmkm6g1f0nxxq1717dircjx8m45ypjq9";
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake pkg-config webos.cmake-modules ];
|
||||
|
||||
buildInputs = [ libusb-compat-0_1 ];
|
||||
|
||||
# Workaround build failure on -fno-common toolchains:
|
||||
# ld: src/host/usb-linux.c:82: multiple definition of `t_recovery_queue';
|
||||
# src/host/recovery.c:45: first defined here
|
||||
NIX_CFLAGS_COMPILE = "-fcommon";
|
||||
|
||||
cmakeFlags = [ "-DWEBOS_TARGET_MACHINE_IMPL=host" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Daemon for communicating with WebOS devices";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ dtzWill ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
150
pkgs/development/mobile/xcodeenv/build-app.nix
Normal file
150
pkgs/development/mobile/xcodeenv/build-app.nix
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
{stdenv, lib, composeXcodeWrapper}:
|
||||
{ name
|
||||
, src
|
||||
, sdkVersion ? "13.1"
|
||||
, target ? null
|
||||
, configuration ? null
|
||||
, scheme ? null
|
||||
, sdk ? null
|
||||
, xcodeFlags ? ""
|
||||
, release ? false
|
||||
, certificateFile ? null
|
||||
, certificatePassword ? null
|
||||
, provisioningProfile ? null
|
||||
, codeSignIdentity ? null
|
||||
, signMethod ? null
|
||||
, generateIPA ? false
|
||||
, generateXCArchive ? false
|
||||
, enableWirelessDistribution ? false
|
||||
, installURL ? null
|
||||
, bundleId ? null
|
||||
, appVersion ? null
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert release -> certificateFile != null && certificatePassword != null && provisioningProfile != null && signMethod != null && codeSignIdentity != null;
|
||||
assert enableWirelessDistribution -> installURL != null && bundleId != null && appVersion != null;
|
||||
|
||||
let
|
||||
# Set some default values here
|
||||
|
||||
_target = if target == null then name else target;
|
||||
|
||||
_configuration = if configuration == null
|
||||
then
|
||||
if release then "Release" else "Debug"
|
||||
else configuration;
|
||||
|
||||
_sdk = if sdk == null
|
||||
then
|
||||
if release then "iphoneos" + sdkVersion else "iphonesimulator" + sdkVersion
|
||||
else sdk;
|
||||
|
||||
# The following is to prevent repetition
|
||||
deleteKeychain = ''
|
||||
security default-keychain -s login.keychain
|
||||
security delete-keychain $keychainName
|
||||
'';
|
||||
|
||||
xcodewrapperFormalArgs = builtins.functionArgs composeXcodeWrapper;
|
||||
xcodewrapperArgs = builtins.intersectAttrs xcodewrapperFormalArgs args;
|
||||
xcodewrapper = composeXcodeWrapper xcodewrapperArgs;
|
||||
|
||||
extraArgs = removeAttrs args ([ "name" "scheme" "xcodeFlags" "release" "certificateFile" "certificatePassword" "provisioningProfile" "signMethod" "generateIPA" "generateXCArchive" "enableWirelessDistribution" "installURL" "bundleId" "version" ] ++ builtins.attrNames xcodewrapperFormalArgs);
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
name = lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
|
||||
buildPhase = ''
|
||||
# Be sure that the Xcode wrapper has priority over everything else.
|
||||
# When using buildInputs this does not seem to be the case.
|
||||
export PATH=${xcodewrapper}/bin:$PATH
|
||||
|
||||
${lib.optionalString release ''
|
||||
export HOME=/Users/$(whoami)
|
||||
keychainName="$(basename $out)"
|
||||
|
||||
# Create a keychain
|
||||
security create-keychain -p "" $keychainName
|
||||
security default-keychain -s $keychainName
|
||||
security unlock-keychain -p "" $keychainName
|
||||
|
||||
# Import the certificate into the keychain
|
||||
security import ${certificateFile} -k $keychainName -P "${certificatePassword}" -A
|
||||
|
||||
# Grant the codesign utility permissions to read from the keychain
|
||||
security set-key-partition-list -S apple-tool:,apple: -s -k "" $keychainName
|
||||
|
||||
# Determine provisioning ID
|
||||
PROVISIONING_PROFILE=$(grep UUID -A1 -a ${provisioningProfile} | grep -o "[-A-Za-z0-9]\{36\}")
|
||||
|
||||
if [ ! -f "$HOME/Library/MobileDevice/Provisioning Profiles/$PROVISIONING_PROFILE.mobileprovision" ]
|
||||
then
|
||||
# Copy provisioning profile into the home directory
|
||||
mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
|
||||
cp ${provisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$PROVISIONING_PROFILE.mobileprovision"
|
||||
fi
|
||||
|
||||
# Check whether the identity can be found
|
||||
security find-identity -p codesigning $keychainName
|
||||
''}
|
||||
|
||||
# Do the building
|
||||
export LD=/usr/bin/clang # To avoid problem with -isysroot parameter that is unrecognized by the stock ld. Comparison with an impure build shows that it uses clang instead. Ugly, but it works
|
||||
|
||||
xcodebuild -target ${_target} -configuration ${_configuration} ${lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateIPA || generateXCArchive then "-archivePath \"${name}.xcarchive\" archive" else ""} ${if release then '' PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"'' else ""} ${xcodeFlags}
|
||||
|
||||
${lib.optionalString release ''
|
||||
${lib.optionalString generateIPA ''
|
||||
# Create export plist file
|
||||
cat > "${name}.plist" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>signingCertificate</key>
|
||||
<string>${codeSignIdentity}</string>
|
||||
<key>provisioningProfiles</key>
|
||||
<dict>
|
||||
<key>${bundleId}</key>
|
||||
<string>$PROVISIONING_PROFILE</string>
|
||||
</dict>
|
||||
<key>signingStyle</key>
|
||||
<string>manual</string>
|
||||
<key>method</key>
|
||||
<string>${signMethod}</string>
|
||||
${lib.optionalString (signMethod == "enterprise" || signMethod == "ad-hoc") ''
|
||||
<key>compileBitcode</key>
|
||||
<false/>
|
||||
''}
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
# Produce an IPA file
|
||||
xcodebuild -exportArchive -archivePath "${name}.xcarchive" -exportOptionsPlist "${name}.plist" -exportPath $out
|
||||
|
||||
# Add IPA to Hydra build products
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist \"$(echo $out/*.ipa)\"" > $out/nix-support/hydra-build-products
|
||||
|
||||
${lib.optionalString enableWirelessDistribution ''
|
||||
# Add another hacky build product that enables wireless adhoc installations
|
||||
appname="$(basename "$(echo $out/*.ipa)" .ipa)"
|
||||
sed -e "s|@INSTALL_URL@|${installURL}?bundleId=${bundleId}\&version=${appVersion}\&title=$appname|" ${./install.html.template} > $out/''${appname}.html
|
||||
echo "doc install \"$out/''${appname}.html\"" >> $out/nix-support/hydra-build-products
|
||||
''}
|
||||
''}
|
||||
${lib.optionalString generateXCArchive ''
|
||||
mkdir -p $out
|
||||
mv "${name}.xcarchive" $out
|
||||
''}
|
||||
|
||||
# Delete our temp keychain
|
||||
${deleteKeychain}
|
||||
''}
|
||||
'';
|
||||
|
||||
failureHook = lib.optionalString release deleteKeychain;
|
||||
|
||||
installPhase = "true";
|
||||
} // extraArgs)
|
||||
33
pkgs/development/mobile/xcodeenv/compose-xcodewrapper.nix
Normal file
33
pkgs/development/mobile/xcodeenv/compose-xcodewrapper.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{stdenv}:
|
||||
{version ? "11.1", xcodeBaseDir ? "/Applications/Xcode.app"}:
|
||||
|
||||
assert stdenv.isDarwin;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "xcode-wrapper-"+version;
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
cd $out/bin
|
||||
ln -s /usr/bin/xcode-select
|
||||
ln -s /usr/bin/security
|
||||
ln -s /usr/bin/codesign
|
||||
ln -s /usr/bin/xcrun
|
||||
ln -s /usr/bin/plutil
|
||||
ln -s /usr/bin/clang
|
||||
ln -s /usr/bin/lipo
|
||||
ln -s /usr/bin/file
|
||||
ln -s /usr/bin/rev
|
||||
ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild"
|
||||
ln -s "${xcodeBaseDir}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator"
|
||||
|
||||
cd ..
|
||||
ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"
|
||||
|
||||
# Check if we have the xcodebuild version that we want
|
||||
if [ -z "$($out/bin/xcodebuild -version | grep -x 'Xcode ${version}')" ]
|
||||
then
|
||||
echo "We require xcodebuild version: ${version}"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
||||
15
pkgs/development/mobile/xcodeenv/default.nix
Normal file
15
pkgs/development/mobile/xcodeenv/default.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{ stdenv, lib }:
|
||||
|
||||
rec {
|
||||
composeXcodeWrapper = import ./compose-xcodewrapper.nix {
|
||||
inherit stdenv;
|
||||
};
|
||||
|
||||
buildApp = import ./build-app.nix {
|
||||
inherit stdenv lib composeXcodeWrapper;
|
||||
};
|
||||
|
||||
simulateApp = import ./simulate-app.nix {
|
||||
inherit stdenv lib composeXcodeWrapper;
|
||||
};
|
||||
}
|
||||
25
pkgs/development/mobile/xcodeenv/install.html.template
Normal file
25
pkgs/development/mobile/xcodeenv/install.html.template
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Install IPA</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a id="forwardlink" href="@INSTALL_URL@">Go to the install page or wait a second</a>
|
||||
|
||||
<script type="text/javascript">
|
||||
setTimeout(function() {
|
||||
var link = document.getElementById('forwardlink');
|
||||
|
||||
if(document.createEvent) {
|
||||
var eventObj = document.createEvent('MouseEvents');
|
||||
eventObj.initEvent('click', true, false);
|
||||
link.dispatchEvent(eventObj);
|
||||
} else if(document.createEventObject) {
|
||||
link.fireEvent('onclick');
|
||||
}
|
||||
}, 1000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
56
pkgs/development/mobile/xcodeenv/simulate-app.nix
Normal file
56
pkgs/development/mobile/xcodeenv/simulate-app.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{stdenv, lib, composeXcodeWrapper}:
|
||||
{name, app ? null, bundleId ? null, ...}@args:
|
||||
|
||||
assert app != null -> bundleId != null;
|
||||
|
||||
let
|
||||
xcodewrapperArgs = builtins.intersectAttrs (builtins.functionArgs composeXcodeWrapper) args;
|
||||
|
||||
xcodewrapper = composeXcodeWrapper xcodewrapperArgs;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = lib.replaceChars [" "] [""] name;
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/run-test-simulator << "EOF"
|
||||
#! ${stdenv.shell} -e
|
||||
|
||||
if [ "$1" = "" ]
|
||||
then
|
||||
# Show the user the possibile UDIDs and let him pick one, if none is provided as a command-line parameter
|
||||
xcrun simctl list
|
||||
|
||||
echo "Please provide a UDID of a simulator:"
|
||||
read udid
|
||||
else
|
||||
# If a parameter has been provided, consider that a device UDID and use that
|
||||
udid="$1"
|
||||
fi
|
||||
|
||||
# Open the simulator instance
|
||||
open -a "$(readlink "${xcodewrapper}/bin/Simulator")" --args -CurrentDeviceUDID $udid
|
||||
|
||||
${lib.optionalString (app != null) ''
|
||||
# Copy the app and restore the write permissions
|
||||
appTmpDir=$(mktemp -d -t appTmpDir)
|
||||
cp -r "$(echo ${app}/*.app)" "$appTmpDir"
|
||||
chmod -R 755 "$(echo $appTmpDir/*.app)"
|
||||
|
||||
# Wait for the simulator to start
|
||||
echo "Press enter when the simulator is started..."
|
||||
read
|
||||
|
||||
# Install the app
|
||||
xcrun simctl install "$udid" "$(echo $appTmpDir/*.app)"
|
||||
|
||||
# Remove the app tempdir
|
||||
rm -Rf $appTmpDir
|
||||
|
||||
# Launch the app in the simulator
|
||||
xcrun simctl launch $udid "${bundleId}"
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/run-test-simulator
|
||||
''}
|
||||
'';
|
||||
}
|
||||
39
pkgs/development/mobile/xpwn/default.nix
Normal file
39
pkgs/development/mobile/xpwn/default.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{ lib, stdenv, fetchFromGitHub, cmake, zlib, libpng, bzip2, libusb-compat-0_1, openssl }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "xpwn";
|
||||
version = "0.5.8git";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "planetbeing";
|
||||
repo = pname;
|
||||
rev = "ac362d4ffe4d0489a26144a1483ebf3b431da899";
|
||||
sha256 = "1qw9vbk463fpnvvvfgzxmn9add2p30k832s09mlycr7z1hrh3wyf";
|
||||
};
|
||||
|
||||
# Workaround build failure on -fno-common toolchains:
|
||||
# ld: ../ipsw-patch/libxpwn.a(libxpwn.c.o):(.bss+0x4): multiple definition of
|
||||
# `endianness'; CMakeFiles/xpwn-bin.dir/src/xpwn.cpp.o:(.bss+0x0): first defined here
|
||||
NIX_CFLAGS_COMPILE = "-fcommon";
|
||||
|
||||
preConfigure = ''
|
||||
rm BUILD # otherwise `mkdir build` fails on case insensitive file systems
|
||||
sed -r -i \
|
||||
-e 's/(install.*TARGET.*DESTINATION )\.\)/\1bin)/' \
|
||||
-e 's!(install.*(FILE|DIR).*DESTINATION )([^)]*)!\1share/xpwn/\3!' \
|
||||
*/CMakeLists.txt
|
||||
sed -i -e '/install/d' CMakeLists.txt
|
||||
'';
|
||||
|
||||
strictDeps = true;
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ zlib libpng bzip2 libusb-compat-0_1 openssl ];
|
||||
|
||||
meta = with lib; {
|
||||
broken = stdenv.isDarwin;
|
||||
homepage = "http://planetbeing.lighthouseapp.com/projects/15246-xpwn";
|
||||
description = "Custom NOR firmware loader/IPSW generator for the iPhone";
|
||||
license = licenses.gpl3Plus;
|
||||
platforms = with platforms; linux ++ darwin;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue