-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
151 lines (130 loc) · 3.97 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
{
description = "flutter development";
inputs = {
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
systems.url = "github:nix-systems/default";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
android-nixpkgs = {
url = "github:tadfisher/android-nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.devshell.follows = "devshell";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
android-nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config = {
android_sdk.accept_license = true;
allowUnfree = true;
};
};
# Everything to make Flutter happy
sdk = android-nixpkgs.sdk.${system} (sdkPkgs:
with sdkPkgs; [
cmdline-tools-latest
build-tools-30-0-3
build-tools-34-0-0
platform-tools
emulator
#patcher-v4
platforms-android-34
]);
pinnedJDK = pkgs.jdk17;
pinnedFlutter = pkgs.flutter;
shellSh =
/*
sh
*/
''
export PATH="$PATH":"$HOME/.pub-cache/bin"
session="octimemo-flutter"
sessionExist=$(tmux list-sessions | grep $session)
if [ "$sessionExist" != "" ]; then
tmux kill-session -t $session
fi
window=0
tmux -L $session new-session -d -s $session
# Set tmux options
tmux -L $session set -g mouse on
tmux -L $session set -g mouse-select-window on
# Create the first window and run nvim
tmux -L $session send-keys -t $session 'nvim ./lib' C-m
# Split the window and run flutter
tmux -L $session split-window -v -t $session:0.0
tmux -L $session send-keys -t $session 'flutter run --flavor development --target ./lib/main_development.dart --debug' C-m
# Select the first pane
tmux -L $session select-pane -t 0
# Attach to the session
tmux -L $session attach-session -t $session
'';
in {
# don't need to write the <system> part
# because we inherited system in pkgs
devShells = {
default = pkgs.mkShell {
name = "octimemo-devshell";
buildInputs = [
# Android
pinnedJDK
sdk
# Flutter
pinnedFlutter
# Code hygiene
pkgs.gitlint
];
# android specific envs
ANDROID_HOME = "${sdk}/share/android-sdk";
ANDROID_SDK_ROOT = "${sdk}/share/android-sdk";
JAVA_HOME = pinnedJDK;
GRADLE_USER_HOME = "/home/qq/.gradle";
# Fix an issue with Flutter using an older version of aapt2, which does not know
# an used parameter.
#GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${sdk}/share/android-sdk/build-tools/34.0.0/aapt2";
shellHook = shellSh;
};
pc = {
buildInputs = with pkgs; [
# Flutter
flutter
# Code hygiene
gitlint
# Flutter dependencies for linux desktop
atk
cairo
clang
cmake
epoxy
gdk-pixbuf
glib
gtk3
harfbuzz
ninja
pango
pcre
pkg-config
xorg.libX11
xorg.xorgproto
];
# Make Flutter build on desktop
CPATH = "${pkgs.xorg.libX11.dev}/include:${pkgs.xorg.xorgproto}/include";
LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [atk cairo epoxy gdk-pixbuf glib gtk3 harfbuzz pango];
shellHook = shellSh;
};
};
});
}