-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefault.nix
120 lines (98 loc) · 2.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
with ( import (builtins.fetchGit {
# Descriptive name to make the store path easier to identify
name = "nixos-20.03";
url = "https://github.com/nixos/nixpkgs-channels/";
# Commit hash :
# `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-20.03`
ref = "refs/heads/nixos-20.03";
rev = "9ea61f7bc4454734ffbff73c9b6173420fe3147b";
}) {
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
});
let
drvName = "count";
androidComposition = androidenv.composeAndroidPackages {
toolsVersion = "26.1.1";
platformToolsVersion = "28.0.1";
platformVersions = [
"28"
];
includeExtras = [
];
};
fhsEnv = buildFHSUserEnv rec {
name = "${drvName}-fhs-env";
multiPkgs = pkgs: with pkgs; [
coreutils
];
extraInstallCommands = ''
cat <<'EOF' >$out/bin/init-${name}
# make writable sdk copy
mkdir -p "$ANDROID_SDK_ROOT"
cp -Lr \
"${androidComposition.androidsdk}/libexec/android-sdk/." \
"$ANDROID_SDK_ROOT"
chmod -R u+w "$ANDROID_SDK_ROOT"
EOF
chmod +x "$out/bin/init-${name}"
source ${makeWrapper}/nix-support/setup-hook
wrapProgram $out/bin/${name} \
--set JAVA_HOME "${openjdk}" \
--set CHROME_BIN "${chromium}/bin/chromium" \
--run "init-${name}"
'';
};
in
stdenv.mkDerivation {
name = "${drvName}";
nativeBuildInputs = [
fhsEnv
];
buildInputs = [
coreutils
git
androidComposition.androidsdk
nodejs
gradle
openjdk
peek # screen recorder
unzip
];
shellHook = ''
export NPM_CONFIG_PREFIX="$PWD/.npm-global"
export PATH="''${PATH}:''${NPM_CONFIG_PREFIX}/bin"
${nodejs}/bin/npm set prefix "''${NPM_CONFIG_PREFIX}/.npm-global"
ionic() { ${nodejs}/bin/npx ionic "''$@"; }
export -f ionic
ng() { ${nodejs}/bin/npx ng "''$@"; }
export -f ng
ncu() { ${nodejs}/bin/npx ncu "''$@"; }
export -f ncu
build() {
STOREPASS="''${1?Missing Storepass first argument}" && shift
${nodejs}/bin/npm install
${nodejs}/bin/npx ionic cordova build android "''${@}"
export STOREPASS
find \
platforms/ \
-name '*.apk' \
-print0 \
| xargs -0 -n1 -I{} \
./apk_finalize.sh \
{} \
"count.apk"
}
export -f build
buildRelease() {
STOREPASS="''${1?Missing Storepass first argument}" && shift
build "''${STOREPASS}" --prod --release "''${@}"
}
export -f buildRelease
export ANDROID_SDK_ROOT="$PWD/.android-sdk"
export ANDROID_HOME="$ANDROID_SDK_ROOT"
exec ${fhsEnv}/bin/${drvName}-fhs-env
'';
}