-
Notifications
You must be signed in to change notification settings - Fork 164
/
default.nix
156 lines (128 loc) · 4.75 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
env@{
nixpkgs
, nixpkgsCross
, ghcAndroidAarch64
, ghcAndroidAarch32
, overrideCabal
, acceptAndroidSdkLicenses
}:
with nixpkgs.lib.strings;
let impl = import ./impl.nix env;
in rec {
# URI information that becomes AndroidManifest.xml content for additional intent filters.
intentFilterXml = {
scheme
# URL scheme
# E.g.: "https"
, host
, port ? null
# Port number or null
# E.g.: 8000
, pathPrefix ? ""
}: impl.intentFilterXml {
inherit scheme
host
port
pathPrefix;
};
defaultResources = ./res;
defaultAssets = ./assets;
defaultIconPath = "@drawable/ic_launcher";
buildIcons = nixpkgs.callPackage ./buildIcons.nix {};
buildApp = {
package
# A function from haskellPackages to the package we'd like to turn into
# an APK
# E.g.: (p: p.hello)
, executableName
# The name of the executable in the Cabal file that will become the main
# Activity in the Android package
# E.g.: "hello"
, applicationId
# The [Application ID](https://developer.android.com/studio/build/application-id.html)
# for your Android package
# E.g.: "com.example.myapp"
, displayName
# The app name that will be displayed to the user
# E.g.: "Hello, world!"
, version ? {
code = "1";
# Must be a monotonically increasing number; defines what it means to "upgrade" the app
name = "1.0";
# The version that is displayed to the end user
}
, releaseKey ? null
#TODO: Factor out signing into a separate step
# To create a release build, set this to a value like:
# { storeFile = ./path/to/keystore;
# storePassword = "password";
# keyAlias = "myKey";
# keyPassword = "password";
# }
, isRelease ? releaseKey != null
, resources ? defaultResources
, assets ? defaultAssets
, iconPath ? defaultIconPath
, activityAttributes ? ""
# Additional activity attributes like: android:launchMode="singleInstance"
, permissions ? ""
# Manifest XML for additional permissions
, services ? ""
, intentFilters ? ""
# Manifest XML for additional intent filters
# E.g.: concatStrings (map intentFilterXml deepLinkUris);
, googleServicesJson ? null
, mavenDeps ? import ./defaults/deps.nix
, additionalDependencies ? ""
, runtimeSharedLibs ? (_: [])
# Allows to copy native .so libraries into APK. Example:
# runtimeSharedLibs = nixpkgs: [
# "${nixpkgs.libsodium}/lib/libsodium.so"
# ];
#
# Note that android linker doesn't support versioned libraries, so
# for instance libz.so.1 won't be copied by gradle into resulted APK.
# You need to patch soname in make files of libraries to link against
# unversioned libraries.
, javaSources ? (androidActivitySrc: mainWidgetSrc: [ androidActivitySrc mainWidgetSrc ])
# A function that is used to build the list of android source files. The
# arguments to this function are:
# * The default android-activity java source tree (from the [android-activity package](https://hackage.haskell.org/package/android-activity))
# * The default "main widget" java source tree (from [reflex-dom](https://github.com/reflex-frp/reflex-dom/blob/develop/reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java))
# Those arguments can be selectively ignored and replaced with alternate
# implementations. Additional Java source directories can also be added
# to the list for inclusion in the APK build
, universalApk ? true
# Set this to false to build one APK per target platform. This will
# automatically transform the version code to 1000 * versionCode + offset
# where "offset" is a per-platform constant.
, usesCleartextTraffic ? false
# Can be "assembleRelease", "assembleDebug", or "bundleRelease"
, gradleTask ? (if isRelease then "assembleRelease" else "assembleDebug")
}:
assert builtins.match "^([A-Za-z][A-Za-z0-9_]*\\.)*[A-Za-z][A-Za-z0-9_]*$" applicationId != null;
nixpkgs.lib.makeOverridable impl.buildApp {
inherit package
acceptAndroidSdkLicenses
executableName
applicationId
displayName
version
releaseKey
resources
assets
iconPath
activityAttributes
permissions
services
intentFilters
googleServicesJson
additionalDependencies
runtimeSharedLibs
javaSources
universalApk
mavenDeps
usesCleartextTraffic
gradleTask;
};
}