-
Notifications
You must be signed in to change notification settings - Fork 20
/
flake.nix
87 lines (77 loc) · 2.79 KB
/
flake.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
# Flake Shell for building release artifacts for swift and kotlin
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
fenix = {
url = "github:nix-community/fenix";
inputs = { nixpkgs.follows = "nixpkgs"; };
};
flake-utils = { url = "github:numtide/flake-utils"; };
};
outputs = { nixpkgs, flake-utils, fenix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (pkgs.stdenv) isDarwin;
inherit (pkgs) androidenv;
inherit (androidComposition) androidsdk;
frameworks = if isDarwin then pkgs.darwin.apple_sdk.frameworks else null;
pkgs = import nixpkgs {
inherit system;
# Rust Overlay
overlays = [ fenix.overlays.default ];
config = {
android_sdk.accept_license = true;
allowUnfree = true;
};
};
android = {
platforms = [ "34" ];
platformTools = "33.0.3";
buildTools = [ "30.0.3" ];
};
sdkArgs = {
platformVersions = android.platforms;
platformToolsVersion = android.platformTools;
buildToolsVersions = android.buildTools;
includeNDK = true;
};
fenixPkgs = fenix.packages.${system};
# Pinned Rust Version
rust-toolchain = fenixPkgs.fromToolchainFile {
file = ./rust-toolchain;
sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk=";
};
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md
androidHome = "${androidComposition.androidsdk}/libexec/android-sdk";
androidComposition = androidenv.composeAndroidPackages sdkArgs;
# Packages available to flake while building the environment
nativeBuildInputs = with pkgs; [ pkg-config ];
# Define the packages available to the build environment
# https://search.nixos.org/packages
buildInputs = with pkgs; [
rust-toolchain
kotlin
androidsdk
jdk17
cargo-ndk
# System Libraries
sqlite
openssl
] ++ lib.optionals isDarwin [ # optional packages if on darwin, in order to check if build passes locally
libiconv
frameworks.CoreServices
frameworks.Carbon
frameworks.ApplicationServices
frameworks.AppKit
darwin.cctools
];
in {
devShells.default = pkgs.mkShell {
OPENSSL_DIR = "${pkgs.openssl.dev}";
ANDROID_HOME = androidHome;
ANDROID_SDK_ROOT = androidHome; # ANDROID_SDK_ROOT is deprecated, but some tools may still use it;
ANDROID_NDK_ROOT = "${androidHome}/ndk-bundle";
inherit buildInputs nativeBuildInputs;
};
});
}