-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
executable file
·131 lines (126 loc) · 5.16 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
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
{
description = "Flutter toolchain. Installs all tools needed for flutter, with versions pinned for this project. Rust's own tooling handles the rust toolchain.";
# nix flutter doesn't work: https://github.com/NixOS/nixpkgs/issues/243448
# thus using a local installation
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
android-nixpkgs = {
url = "github:tadfisher/android-nixpkgs";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
devshell.follows = "devshell";
};
};
devshell = {
url = "github:numtide/devshell";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
# share rust configuration with nix ... not really needed!
# rust-overlay = {
# url = "github:oxalica/rust-overlay";
# inputs = {
# nixpkgs.follows = "nixpkgs";
# flake-utils.follows = "flake-utils";
# };
# };
#
# workaround (using the last working version)
# until https://github.com/NixOS/nixpkgs/issues/327836 and https://github.com/NixOS/nixpkgs/issues/242779 are fixed
# needs PR https://github.com/NixOS/nixpkgs/pull/346043 and https://github.com/NixOS/nixpkgs/pull/346947 to be merged
# using last know version where swift wasn't broken
swift-nixpkgs.url = "github:nixos/nixpkgs?rev=2e92235aa591abc613504fde2546d6f78b18c0cd";
};
# outputs = { nixpkgs, flake-utils, android-nixpkgs, rust-overlay, swift-nixpkgs, ... }:
outputs = { nixpkgs, flake-utils, android-nixpkgs, swift-nixpkgs, ... }:
# outputs = { nixpkgs, flake-utils, android-nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
swift-pkgs = import swift-nixpkgs {
inherit system;
};
# overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
# inherit system overlays;
inherit system;
config = {
allowUnfree = true;
android_sdk = {
accept_license = true;
};
};
};
# rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
androidCustomPackage = android-nixpkgs.sdk.${system} (
sdkPkgs: with sdkPkgs; [
cmdline-tools-latest
build-tools-30-0-3
# build-tools-33-0-2
build-tools-34-0-0
ndk-23-1-7779620
# ndk-26-2-11394342
platform-tools
emulator
#patcher-v4
# platforms-android-28
platforms-android-33
platforms-android-34
system-images-android-34-aosp-atd-arm64-v8a #basic image, 40% faster
system-images-android-34-google-apis-arm64-v8a #google branded
system-images-android-34-google-apis-playstore-arm64-v8a #google branded with playstore installed
]
);
pinnedJDK = pkgs.jdk17;
xcode_version = "15.4.0";
frb_version = "latest";
flutter_rust_bridge_codegen = import ./nix/flutter_rust_bridge_codegen.nix {
inherit pkgs frb_version;
};
appleInputs =
if builtins.elem system [ "aarch64-darwin" "x86_64-darwin" ] then [
pkgs.cocoapods
swift-pkgs.xcodes
] else [ ];
in
{
devShells. default = pkgs.mkShellNoCC
{
name = "flutter-rust-dev-shell";
buildInputs = with pkgs; [
just
# rustToolchain
flutter
pinnedJDK
androidCustomPackage
flutter_rust_bridge_codegen
] ++ appleInputs;
JAVA_HOME = pinnedJDK;
# ANDROID_SDK_ROOT = "${androidCustomPackage}/share/android-sdk";
# Use this to create an android emulator
# however, this is not needed, as VSCode's Flutter Plugin can create emulators as well
# AVD_package = "system-images;android-34;aosp_atd;arm64-v8a";
# local_toolchain_path = "$PWD/.toolchain";
# local_SDK_path = "${local_toolchain_path}/android";
# local_AVD_path = "${local_SDK_path}/AVD";
# avdmanager create avd --name android-34-pixel_8 --package '${AVD_package}' --device "pixel_8"
shellHook = ''
# uncomment to enable flutter-rust-bridge-codegen logging
# export RUST_BACKTRACE=1
# export RUST_LOG="debug"
# installs or checks for the right xcode version
echo "installing xcode ${xcode_version}"
xcodes install ${xcode_version} --experimental-unxip # --directory "$PWD/.xcode"
xcodes select ${xcode_version}
echo
# GRADLE_USER_HOME=$HOME/gradle-user-home
# GRADLE_HOME=$HOME/gradle-home
'';
# GRADLE_USER_HOME = " /home/admin0101/.gradle ";
# GRADLE_OPTS = " - Dorg.gradle.project.android.aapt2FromMavenOverride=${androidCustomPackage}/share/android-sdk/build-tools/34.0.0/aapt2";
};
}
);
}