-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathflake.nix
More file actions
311 lines (268 loc) · 8.55 KB
/
Copy pathflake.nix
File metadata and controls
311 lines (268 loc) · 8.55 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# SPDX-License-Identifier: AGPL-3.0
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.git-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
perSystem = {
inputs',
config,
system,
lib,
...
}: let
pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
};
rust = (
with inputs'.fenix.packages;
combine [
stable.toolchain
targets.aarch64-linux-android.stable.rust-std
targets.x86_64-linux-android.stable.rust-std
targets.armv7-linux-androideabi.stable.rust-std
targets.i686-linux-android.stable.rust-std
]
);
platformVersion = "36";
systemImageType = "default";
currentPath = builtins.getEnv "PWD";
androidEnv = pkgs.androidenv.override {licenseAccepted = true;};
androidComp = (
androidEnv.composeAndroidPackages {
cmdLineToolsVersion = "8.0";
includeNDK = true;
buildToolsVersions = ["35.0.0"];
platformVersions = [
"30"
platformVersion
];
includeEmulator = true;
includeSystemImages = true;
systemImageTypes = [
systemImageType
];
abiVersions = [
"x86"
"x86_64"
"armeabi-v7a"
"arm64-v8a"
];
cmakeVersions = ["3.10.2"];
}
);
android-sdk = pkgs.android-studio.withSdk androidComp.androidsdk;
self = inputs.self;
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
nodejs = pkgs.nodejs_24;
pnpm = pkgs.pnpm_10;
pnpmConfigHook = pkgs.pnpmConfigHook.override {inherit pnpm;};
pnpmNativeBuildInputs = [
pkgs.pkg-config
nodejs
pnpm
pnpmConfigHook
];
mkPnpmDeps = {
src,
version,
pnpmInstallFlags,
}:
pkgs.fetchPnpmDeps {
inherit
pnpm
src
version
pnpmInstallFlags
;
pname = "sable";
fetcherVersion = 3;
hash = "sha256-9lHy7/+hVET5c9Mt3F9DvrkW97DMxTISJsrklK/Ls2c=";
};
mkPnpmCheck = name: script:
pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "sable-${name}";
inherit (packageJson) version;
src = lib.cleanSource ./.;
pnpmInstallFlags = ["--ignore-scripts"];
pnpmDeps = mkPnpmDeps {
inherit (finalAttrs) src version pnpmInstallFlags;
};
nativeBuildInputs = pnpmNativeBuildInputs;
buildPhase = ''
runHook preBuild
pnpm run ${script}
runHook postBuild
'';
installPhase = ''
runHook preInstall
touch $out
runHook postInstall
'';
doCheck = false;
});
nativeBuildInputs = with pkgs; [
pkg-config
gobject-introspection
cargo
cargo-tauri
nodejs
xdg-utils
desktop-file-utils
wrapGAppsHook3
];
buildInputs = with pkgs; [
at-spi2-atk
atkmm
cairo
gdk-pixbuf
glib
glib-networking
gtk3
gsettings-desktop-schemas
harfbuzz
librsvg
libsoup_3
pango
webkitgtk_4_1
openssl
dbus
dbus.dev
libayatana-appindicator
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-ugly
gst_all_1.gst-libav
android-sdk
];
defaultPackages = [
nodejs
pnpm
rust
pkgs.cargo
pkgs.cargo-tauri
pkgs.corepack
pkgs.vitejs
pkgs.oxlint
pkgs.oxfmt
pkgs.knope
pkgs.typescript
pkgs.typescript-language-server
pkgs.nil
pkgs.nixd
pkgs.jdk
];
in {
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
oxfmt.enable = true;
};
settings.global.excludes = [
"dist"
"node_modules"
"pnpm-lock.yaml"
"pnpm-workspace.yaml"
"package.json"
"LICENSE"
"CHANGELOG.md"
"./changeset"
];
};
pre-commit.settings.hooks = {
treefmt = {
enable = true;
package = config.treefmt.build.wrapper;
};
};
packages.sable = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "sable";
inherit (packageJson) version;
src = lib.cleanSource ./.;
# ignoring knope for building
pnpmInstallFlags = ["--ignore-scripts"];
pnpmDeps = mkPnpmDeps {
inherit (finalAttrs) src version pnpmInstallFlags;
};
nativeBuildInputs = pnpmNativeBuildInputs;
env.VITE_BUILD_HASH = self.shortRev or self.dirtyShortRev or "";
env.VITE_IS_RELEASE_TAG = "false";
buildPhase = ''
runHook preBuild
pnpm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r dist $out
runHook postInstall
'';
});
packages.android-emulator = androidEnv.emulateApp {
name = "emulate-sable";
platformVersion = platformVersion;
abiVersion = "x86_64"; # arm64-v8a
systemImageType = systemImageType;
};
packages.default = config.packages.sable;
checks = {
build = config.packages.sable;
lint = mkPnpmCheck "lint" "lint";
fmt = mkPnpmCheck "fmt" "fmt:check";
test = mkPnpmCheck "test" "test:run";
typecheck = mkPnpmCheck "typecheck" "typecheck";
knip = mkPnpmCheck "knip" "knip";
};
devShells = {
default = pkgs.mkShell {
inherit buildInputs nativeBuildInputs;
packages = defaultPackages;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (nativeBuildInputs ++ buildInputs);
GIO_EXTRA_MODULES = "${pkgs.glib-networking}/lib/gio/modules";
GST_PLUGIN_SYSTEM_PATH = "${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
android = pkgs.mkShell {
inherit buildInputs nativeBuildInputs;
packages = defaultPackages ++ [
android-sdk
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (nativeBuildInputs ++ buildInputs);
ANDROID_HOME = "${androidComp.androidsdk}/libexec/android-sdk";
ANDROID_SDK_ROOT = "${androidComp.androidsdk}/libexec/android-sdk";
ANDROID_NDK_ROOT = "${androidComp.androidsdk}/libexec/android-sdk/ndk-bundle";
GIO_EXTRA_MODULES = "${pkgs.glib-networking}/lib/gio/modules";
GST_PLUGIN_SYSTEM_PATH = "${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
};
};
};
}