forked from tadfisher/android-nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hm-module.nix
59 lines (52 loc) · 1.34 KB
/
hm-module.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
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.android-sdk;
in
{
options.android-sdk = {
enable = mkEnableOption "android SDK environment";
path = mkOption {
type = types.str;
default = "${config.xdg.dataHome}/android";
defaultText = "$XDG_DATA_HOME/android";
description = ''
Path to install the SDK environment, relative to
<varname>home.homeDirectory</varname>.
'';
};
packages = mkOption {
default = self: [ self.cmdline-tools-latest ];
type = hm.types.selectorFunction;
defaultText = "sdk: [ sdk.cmdline-tools-latest ]";
example = literalExample ''
sdk: with sdk; [
build-tools-32-0-0
cmdline-tools-latest
emulator
platforms-android-31
sources-android-31
]
'';
};
finalPackage = mkOption {
type = types.package;
visible = false;
readOnly = true;
description = ''
Final Android SDK environment.
'';
};
};
config = mkIf (cfg.enable) {
android-sdk.finalPackage = pkgs.androidSdk cfg.packages;
home = {
file.${cfg.path}.source = "${cfg.finalPackage}/share/android-sdk";
packages = [ cfg.finalPackage ];
sessionVariables = {
ANDROID_HOME = cfg.path;
ANDROID_SDK_ROOT = cfg.path;
};
};
};
}