nandi/frqpublic Fork 0
7a293a9096b4109669742097f41382365089dc7f
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

flake.nix · 497 lines · 23.4 KBNix Blame HistoryRaw
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago1{
2 # frq is Jolt source, so "building" it is three things, not one:
3 #
4 # jolt the runtime that reads it (github:jolt-lang/jolt)
5 # jolt-native libvidya and libjoltmoq, in Rust (gitlab:nandithebull/jolt-native)
6 # frq this tree, with its deps resolved to store paths
7 #
8 # Jolt resolves deps.edn by running git at startup, which a build sandbox has
9 # no network for — so every dep is fetched by Nix instead and handed back as
10 # a :local/root through -Sdeps.
11 #
12 # nix build .#frq && ./result/bin/frq
13 #
14 # On a machine that is not NixOS the GL driver is the host's and the loader
15 # will not find it, so the window never opens ("GL display: argument does not
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago16 # name a valid config"). The launcher handles that itself: off NixOS it hands
17 # the process to nixGL, which puts the host's driver ahead of the store's.
18 # Nothing extra to type, and a distrobox/container Arch is the same case as
19 # a bare one.
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago20 description = "frq a freeq client in jolt";
21
22 inputs = {
23 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago24 # `git+https` with `?submodules=1` rather than the github scheme: Jolt's
25 # own flake declares `self.submodules`, which this Nix rejects when the
26 # flake is fetched as `github:`. Its outputs are not what we take — the
27 # runtime is built here, by joltFrom — but it is a flake all the same, so
28 # its own inputs are locked with ours rather than left to float, and
29 # `vendor/` comes along as the submodule the build needs.
30 #
31 # The fork rather than jolt-lang/jolt: it is what jolt-android-src already
32 # pins for the boot image, and a desktop runtime built from a different
33 # tree than the APK's is the same drift the jolt-native comment warns
34 # about. Unpinned here — the desktop follows the fork's main, while the
35 # APK stays on the rev below.
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago36 jolt-src = {
Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago37 url = "git+https://gitlab.com/nandithebull/jolt?submodules=1";
38 inputs.nixpkgs.follows = "nixpkgs";
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago39 };
40
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago41 # The source half of jolt-native: the Jolt code under glimmer-backends/ that
42 # binds the native objects, and the flake that builds the desktop ones. The
43 # Android objects no longer come from here — jolt-native-android below
44 # fetches those prebuilt — so this input is what `just run` builds against
45 # and what an APK's Clojure side is read from, both at this rev.
Take the jolt-native ahead of the release, since a run can build it 36f6c77 nandi 17d ago46 #
47 # Pinned all the same, and pinned to a rev: this input carries both halves of
Pin the native half to the release the rest of the tree names cb7f9f1 nandi 17d ago48 # glimmer-vidya — libvidya, and the Jolt side that binds it — so an
49 # unpinned `main` is a build whose native half is free to sit at a
50 # different commit from the tree that talks to it. It did, and what the
51 # drift cost was silence: the Jolt half sent a reaction pill's hover card
52 # to a libvidya with no handler for one, and the pill said nothing.
Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago53 # It also carries the terminal backend — crates/jolt-tui, the same tree ABI
54 # over a grid of cells, and jolt/glimmer-tui beside glimmer-vidya. That was
55 # a second input at a second rev while it lived on a branch, which is the
56 # drift this comment warns about wearing a different hat: one input, and
57 # the window and the terminal are the same library either way.
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago58 jolt-native = {
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago59 url = "git+https://gitlab.com/nandithebull/jolt-native?rev=d970307ccf1fe67e2e971f2837d2282d8ba79a62";
Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago60 inputs.nixpkgs.follows = "nixpkgs";
Paint the same screens into a terminal ab83b42 nandi 17d ago61 };
62
Build libmoq_ffi ourselves, for the codecs the release leaves out eab184b nandi 9d ago63 # moq-ffi's source, for the object frq.moq.* binds.
64 #
65 # Built here rather than taken from the release, and the reason is a
66 # feature flag: `audio` and `video` are moq-ffi's defaults and are OFF in
67 # the Linux and Android artifacts upstream publishes. Those two carry the
68 # codecs — Opus through moq-audio, H.264 through moq-video's vendored
69 # openh264 — so the published object can move a frame but cannot make one.
70 # A call needs an encoder, so the choice is to build this once or to bind
71 # libopus and openh264 separately and reimplement what moq-video already
72 # does. Once, here.
73 #
74 # It is not free: this is the 440-crate build that fetching avoided, which
75 # makes a substituter matter more now rather than less. What it is not is
76 # a per-build cost — the pin below moves when someone moves it.
77 moq-src = {
78 url = "github:kixelated/moq/moq-ffi-v0.3.17";
79 flake = false;
80 };
81
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago82 # The Android objects, prebuilt by jolt-native's CI rather than compiled
83 # here: an APK needs libvidya and libjoltmoq for arm64, and building them
84 # locally means an NDK, a Rust cross toolchain and the whole crane graph
85 # for two files that upstream already built and published.
86 #
87 # "latest" is the version its CI overwrites on every default-branch build,
88 # so this input finds a new one on `nix flake update` -- but flake.lock
89 # still records exactly which bytes an APK was built from, which is the
90 # pin that matters. `just bump` decides when to move; this only decides
91 # where to look. The archive is rooted at include/ and lib/arm64-v8a/, so
92 # nothing here has to unpack it.
93 jolt-native-android = {
94 url = "https://gitlab.com/api/v4/projects/nandithebull%2Fjolt-native/packages/generic/jolt-native/latest/android-arm64-v8a.tar.gz";
95 flake = false;
96 };
97
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago98 # Chez itself, because the APK needs a cross target nixpkgs does not
99 # build: frq's Scheme is compiled to an arm64 boot image, and that wants
100 # Chez's own `tarm64le` workarea — boot files, xpatch and libkernel.a.
101 # The version is the one the hand-built tree under ~/.cache used, and the
102 # submodules are not optional (zuo builds it, lz4 and zlib link into it).
Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago103 # The same fork jolt-src takes, built here rather than fetched as a
104 # release binary: upstream reads the socket address out of `struct
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago105 # addrinfo` at glibc's offset, which on Bionic is `ai_canonname`, so an APK
Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago106 # built with upstream cannot open a TLS connection at all. Pinned to a rev
107 # where jolt-src is not: the APK is a release artefact, so its runtime
108 # moves when `just bump` says so rather than when the fork does.
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago109 jolt-android-src = {
110 url = "git+https://gitlab.com/nandithebull/jolt?rev=2b80d68d1f7a31ba92b208b3957e5fb555617ada&submodules=1";
Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago111 inputs.nixpkgs.follows = "nixpkgs";
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago112 };
113
114 chez-src = {
115 url = "git+https://github.com/cisco/ChezScheme?ref=refs/tags/v10.4.1&submodules=1";
116 flake = false;
117 };
118
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago119 # The sha deps.edn pins, on the fork with the reconciler fixes.
120 glimmer = {
121 url = "git+https://gitlab.com/nandithebull/glimmer?rev=399df371c790d690fb6e4560c3d4d7f838502857";
122 flake = false;
123 };
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago124
125 # Only ever used off NixOS, to put the host GL driver on the loader path.
126 nixgl = {
127 url = "github:nix-community/nixGL";
128 inputs.nixpkgs.follows = "nixpkgs";
129 };
Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago130
131 # Wraps a closure into a single self-extracting file. Only the `appimage`
132 # output evaluates it.
133 nix-appimage = {
134 url = "github:ralismark/nix-appimage";
135 inputs.nixpkgs.follows = "nixpkgs";
136 };
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago137 };
138
Build libmoq_ffi ourselves, for the codecs the release leaves out eab184b nandi 9d ago139 outputs = { self, nixpkgs, jolt-src, jolt-native, jolt-native-android, moq-src, glimmer, chez-src, jolt-android-src, nixgl, nix-appimage }:
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago140 let
141 systems = [ "x86_64-linux" "aarch64-linux" ];
142 forEachSystem = f:
143 nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
Run this tree on a native half the builders made a32699e nandi 17d ago144
145 # Mesa, despite the name: it covers Intel and AMD alike. The NVIDIA
146 # wrappers are the ones that need --impure (they read the host kernel
147 # module's version), which is why this only ever reaches for Intel.
Stop carrying the 32-bit GL stack and half of git 040f2c1 nandi 16d ago148 #
149 # Built from nixGL's default.nix rather than taken from its flake
150 # outputs, for the one argument the flake hardcodes on: `enable32bits`,
151 # which on x86_64 puts a second, i686 copy of mesa, its LLVM, and
152 # intel-media-driver into the wrapper. frq is 64-bit on both halves —
153 # the Rust cdylibs and the Chez runtime — so nothing here ever opens the
154 # 32-bit driver, and carrying it is most of the dev shell's closure.
155 nixGLFor = pkgs: (import nixgl {
156 inherit pkgs;
157 enable32bits = false;
158 }).nixGLIntel;
Run this tree on a native half the builders made a32699e nandi 17d ago159
160 # egui reaches for these with dlopen rather than linking them, so being
161 # in the cdylib's buildInputs is not enough — whatever starts frq has to
Follow the xorg renames, and stop wrapping nix in distrobox a400a00 nandi 16d ago162 # put them on the loader path itself. Without libx11 here, vidya reports
Run this tree on a native half the builders made a32699e nandi 17d ago163 # "X11 unavailable", falls back to Wayland, and winit refuses to build a
164 # second event loop after the failed first one.
165 #
166 # Out here rather than beside the package that first needed them: the
167 # dev shell starts frq too, on this tree's source rather than the store's
168 # copy of it, and a second copy of this list is a second chance for the
169 # two ways of running to disagree about what the window needs.
170 runtimeLibsFor = pkgs: with pkgs; [
171 libGL
172 libxkbcommon
173 wayland
Follow the xorg renames, and stop wrapping nix in distrobox a400a00 nandi 16d ago174 libx11
175 libxcursor
176 libxi
177 libxrandr
Run this tree on a native half the builders made a32699e nandi 17d ago178 vulkan-loader
179 ];
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago180 in
181 {
182 packages = forEachSystem (pkgs:
183 let
184 inherit (pkgs) lib;
185
Run this tree on a native half the builders made a32699e nandi 17d ago186 nixGL = nixGLFor pkgs;
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago187
Take the native objects from their own flake rather than rebuilding them 0ee8bba nandi 13d ago188 # libvidya (the retained-tree ABI glimmer-vidya binds, on egui),
189 # libjolttui (the same tree over a grid of cells) and libjoltmoq (the
190 # AV media plane) — one workspace, three cdylibs, taken from
191 # jolt-native's own flake rather than rebuilt here.
192 #
193 # This used to be a rustPlatform.buildRustPackage over the same
194 # source, which meant restating upstream's build: the seven git deps
195 # hashed by hand in `cargoLock.outputHashes` and re-hashed whenever
196 # its Cargo.lock moved, the linuxHeaders path v4l2r's bindgen wants,
197 # and a postPatch dropping the .cargo/config.toml that pointed the
198 # build at DotSlash. Upstream's flake says all of that itself now,
199 # and says it once. It also builds cpal with the `pipewire` feature,
200 # which the restatement did not — so device names in a call are
201 # PipeWire's rather than raw ALSA PCMs.
202 native = jolt-native.packages.${pkgs.stdenv.hostPlatform.system}.default;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago203
Build libmoq_ffi ourselves, for the codecs the release leaves out eab184b nandi 9d ago204 # libmoq_ffi — MoQ over QUIC behind UniFFI's C ABI, with the codecs
205 # in it. This is the object `frq.moq.raw` is generated from.
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago206 #
Build libmoq_ffi ourselves, for the codecs the release leaves out eab184b nandi 9d ago207 # Default features, which is the entire reason this is a build and
208 # not a fetchurl: `audio` and `video` are on by default upstream and
209 # off in every Linux and Android artifact the release publishes, and
210 # they are what carry Opus and H.264. 230 entry points here against
211 # the release object's 206 — see the moq-src input.
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago212 #
Build libmoq_ffi ourselves, for the codecs the release leaves out eab184b nandi 9d ago213 # No cargoHash and no outputHashes: the workspace has no git
214 # dependencies, so its own Cargo.lock is the whole of the pin.
215 moqFfi = pkgs.rustPlatform.buildRustPackage {
216 pname = "libmoq-ffi";
217 version = "0.3.17";
218 src = moq-src;
219 cargoLock.lockFile = "${moq-src}/Cargo.lock";
220
221 # One crate out of a workspace of thirty. Default features are
222 # deliberate — see above — so there is no --no-default-features
223 # here and there should not be.
224 cargoBuildFlags = [ "-p" "moq-ffi" ];
225
226 # The workspace's tests want a network and a relay.
227 doCheck = false;
228
229 # bindgenHook is not optional: moq-video reaches VAAPI through
230 # libva-sys, whose build script runs bindgen, which needs
231 # LIBCLANG_PATH set. Without it the build fails deep inside a
232 # build script with "Unable to find libclang".
233 nativeBuildInputs = with pkgs; [
234 cmake nasm pkg-config perl rustPlatform.bindgenHook
235 ];
236
237 # libva and libdrm are here for their HEADERS. VAAPI itself is
238 # dlopened at runtime, so the object carries no DT_NEEDED for it
239 # and a machine with no VAAPI driver still loads this — openh264
240 # is the fallback, and it is vendored and static.
241 buildInputs = with pkgs; [ openssl libva libdrm ];
242
243 installPhase = ''
244 runHook preInstall
245 mkdir -p $out/lib
246 find target -name 'libmoq_ffi.so' -print -exec cp {} $out/lib/ \;
247 test -f $out/lib/libmoq_ffi.so
248 runHook postInstall
249 '';
250 };
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago251
252 # One directory for the loader to look in. jolt resolves every
253 # :jolt/native name against JOLT_NATIVE_LIB, and the objects now come
254 # from two places — jolt-native's flake, and the moq-ffi release — so
255 # they are joined rather than the path being made a list, which the
256 # loader does not take.
257 nativeAll = pkgs.symlinkJoin {
258 name = "frq-native";
259 paths = [ native moqFfi ];
260 };
261
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago262 # Jolt itself: Clojure on Chez, built the way its own flake builds it.
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago263 # A function, because there are two of them — upstream for the
264 # desktop, and the Bionic-addrinfo fork for the boot image the APK
265 # carries. Nothing else about the build differs.
266 joltFrom = src: pkgs.stdenv.mkDerivation {
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago267 pname = "jolt";
268 version = "dev";
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago269 inherit src;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago270
271 strictDeps = true;
272 nativeBuildInputs = with pkgs; [ chez makeWrapper pkg-config xxd ];
273 buildInputs = with pkgs; [ lz4 zlib ncurses openssl libuuid ];
274
275 JOLT_VERSION = "dev";
276 dontConfigure = true;
277
278 buildPhase = ''
279 runHook preBuild
280 scheme --script host/chez/build-jolt.ss release target/release/jolt
281 runHook postBuild
282 '';
283
284 installPhase = ''
285 runHook preInstall
286 mkdir -p "$out/bin"
287 install -m755 target/release/jolt "$out/bin/jolt"
288 runHook postInstall
289 '';
290
291 # jolt.deps shells out to git and unzip, and jolt.mvn-http dlopens
Stop carrying the 32-bit GL stack and half of git 040f2c1 nandi 16d ago292 # OpenSSL through the JOLT_OPENSSL_LIBDIR seam. gitMinimal rather
293 # than git: all jolt.deps asks for is clone/fetch/rev-parse, and
294 # the full package carries Perl and Python for the subcommands
295 # written in them — a quarter of a gigabyte for git-send-email.
Read the clock in the reader's zone when /etc/localtime is a file bffe879 nandi 18d ago296 #
297 # TZDIR so a zone *name* resolves wherever this runs: frq.clock
298 # hands one to tzset, and glibc then looks for the tzfile under
299 # /usr/share/zoneinfo unless told otherwise — which a NixOS host
300 # does not have. The store's own tzdata is there on both kinds of
301 # machine. --set-default, so a TZDIR the user set still wins.
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago302 postFixup = ''
303 wrapProgram "$out/bin/jolt" \
Stop carrying the 32-bit GL stack and half of git 040f2c1 nandi 16d ago304 --prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.gitMinimal pkgs.unzip ]}" \
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago305 --set-default JOLT_OPENSSL_LIBDIR "${pkgs.lib.makeLibraryPath [ pkgs.openssl ]}" \
Read the clock in the reader's zone when /etc/localtime is a file bffe879 nandi 18d ago306 --set-default TZDIR "${pkgs.tzdata}/share/zoneinfo" \
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago307 --set-default SSL_CERT_FILE "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
308 '';
309 };
310
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago311 joltRuntime = joltFrom jolt-src;
312 joltAndroid = joltFrom jolt-android-src;
313
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago314 # glimmer-vidya lives inside the jolt-native checkout, and its own
315 # deps.edn asks for glimmer by git — the top-level override below
316 # answers for both.
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago317 glimmerVidya = "${jolt-native}/glimmer-backends/glimmer-vidya";
318 glimmerTui = "${jolt-native}/glimmer-backends/glimmer-tui";
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago319
Run this tree on a native half the builders made a32699e nandi 17d ago320 runtimeLibs = runtimeLibsFor pkgs;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago321
322 # The project as jolt sees it: source, deps.edn, nothing else.
323 frqSource = pkgs.runCommand "frq-source" { } ''
324 mkdir -p "$out"
325 cp -r ${self}/src ${self}/deps.edn "$out/"
326 '';
327
328 # Jolt resolves deps.edn from the working directory, so the launcher
329 # runs from the store copy. Its .jolt/cpcache write lands on a
330 # read-only directory and jolt treats that as a quiet cache miss, so
331 # the only cost is re-resolving the (already local) graph per start.
332 frqScript = pkgs.writeShellScript "frq" ''
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago333 export LD_LIBRARY_PATH="${nativeAll}/lib:${lib.makeLibraryPath runtimeLibs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago334 cd ${frqSource}
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago335
336 # On NixOS the store's Mesa is the system's and the window opens.
337 # Anywhere else the real driver is the host's, so defer to nixGL
338 # it prepends the host driver, which has to win over ours.
339 runner=""
340 [ -e /run/current-system ] || runner="${nixGL}/bin/nixGLIntel"
341
342 exec ''${runner} ${joltRuntime}/bin/jolt \
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago343 -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"}}}' \
344 -M:frq "$@"
345 '';
346
Paint the same screens into a terminal ab83b42 nandi 17d ago347 # The same source, the other backend. No GL, no nixGL and no X11 —
348 # a terminal is the one surface that needs nothing from the host but
349 # a terminal, which is the reason this output exists.
350 tuiScript = pkgs.writeShellScript "frq-tui" ''
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago351 export LD_LIBRARY_PATH="${nativeAll}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
Paint the same screens into a terminal ab83b42 nandi 17d ago352 cd ${frqSource}
353
354 exec ${joltRuntime}/bin/jolt \
355 -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"} nandi/glimmer-tui {:local/root "${glimmerTui}"}}}' \
356 -m frq.tui "$@"
357 '';
358
359 tui = pkgs.runCommand "frq-tui-0.1.0"
360 {
361 meta = {
362 description = "frq's screens in a terminal";
363 mainProgram = "frq-tui";
364 platforms = systems;
365 };
366 }
367 ''
368 mkdir -p "$out/bin"
369 ln -s ${tuiScript} "$out/bin/frq-tui"
370 '';
371
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago372 frq = pkgs.runCommand "frq-0.1.0"
373 {
374 meta = {
375 description = "A freeq client in jolt";
376 mainProgram = "frq";
377 platforms = systems;
378 };
379 }
380 ''
381 mkdir -p "$out/bin"
382 ln -s ${frqScript} "$out/bin/frq"
383 '';
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago384 # --- Android ------------------------------------------------------
385 # The SDK and the NDK are Google's, which means unfree and a licence
386 # to accept — so this is its own import of nixpkgs rather than the
387 # `legacyPackages` everything above uses. Confined to the Android
388 # outputs: `nix build` of frq itself never evaluates it.
389 #
Build the APK as derivations only, and retire the buck2 graph 3bc3aaa nandi 16d ago390 # The NDK here is r29, which is the one the pinned libvidya was
391 # built with.
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago392 androidPkgs = import nixpkgs {
393 inherit (pkgs.stdenv.hostPlatform) system;
394 config = {
395 allowUnfree = true;
396 android_sdk.accept_license = true;
397 };
398 };
399
400 androidComposition = androidPkgs.androidenv.composeAndroidPackages {
401 buildToolsVersions = [ "36.0.0" ];
402 platformVersions = [ "36" ];
403 includeNDK = true;
404 };
405
406 android = import ./nix/android.nix {
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago407 inherit pkgs self chez-src jolt-native jolt-native-android glimmer joltAndroid;
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago408 inherit (pkgs) lib;
409 androidSdk = androidComposition.androidsdk;
410 ndk = androidComposition.ndk-bundle;
411 };
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago412 in
413 {
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago414 inherit native moqFfi nativeAll frq;
Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago415 inherit tui;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago416 jolt = joltRuntime;
417 default = frq;
Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago418
419 # frq and everything it loads, squashed into one runnable file for
420 # hosts without Nix. The whole closure rides along — Mesa included,
421 # which is not waste: off NixOS the launcher goes through nixGL, and
422 # nixGL needs a store Mesa to put the host's driver in front of.
423 appimage =
424 nix-appimage.bundlers.${pkgs.stdenv.hostPlatform.system}.default frq;
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago425 }
426 # An APK is built by a linux-x86_64 NDK and a linux-x86_64 jolt, and
427 # Google ships no other; on aarch64 the Android outputs are simply
428 # absent rather than present and broken.
429 // lib.optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") {
430 inherit (android) apk chezAndroid joltBoot libjoltapp;
431 apk-unsigned = android.apk-unsigned;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago432 });
433
Run this tree on a native half the builders made a32699e nandi 17d ago434 # Where `just run` runs, and — because entering it realises what it
435 # names — what builds the half of frq that is not this working tree.
436 #
437 # The two halves, and the split is the whole point of the shell. The frq
438 # source is the files on disk, uncommitted edits and all. Everything
439 # under it — jolt, glimmer, glimmer-vidya, both native objects — is the
440 # flake's, at the revs flake.lock names, so a run says what it ran
441 # against and both halves of glimmer-vidya move together. That is the
442 # drift the `jolt-native` input's comment is about, and a pin frq can
443 # answer for is worth more here than the convenience of a checkout.
444 #
Take the native objects from their own flake rather than rebuilding them 0ee8bba nandi 13d ago445 # `native` is jolt-native's own flake output. It was a buck2 graph when
446 # this comment was first written and a cargo build restated here when it
447 # was second: buck2 fetches its rustc, zig and every third-party crate as
448 # it goes and writes buck-out into the tree it builds, so a sandbox with
449 # no network and a read-only store was the one place it could not run.
450 # Upstream builds with nix now, so the thing its CI runs and the thing
451 # this shell hands a builder are the same derivation.
Run this tree on a native half the builders made a32699e nandi 17d ago452 #
453 # Nothing here says "nixbuild", though: it is a plain derivation, and
Inline the babashka scripts into the justfile 76dcc6c nandi 11d ago454 # where it gets built is the machine's business. The `run` recipe asks for
Run this tree on a native half the builders made a32699e nandi 17d ago455 # the shell with --max-jobs 0, which is what sends it to the `builders`
456 # entry rather than compiling egui on a laptop.
457 devShells = forEachSystem (pkgs:
458 let
459 inherit (pkgs) lib;
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago460 inherit (self.packages.${pkgs.stdenv.hostPlatform.system}) jolt native nativeAll;
Run this tree on a native half the builders made a32699e nandi 17d ago461 in
462 {
463 default = pkgs.mkShellNoCC {
464 name = "frq";
465
466 # jolt, because the runtime frq is run by should be the flake's
467 # too. nixGL for the same reason the launcher reaches for it — see
Inline the babashka scripts into the justfile 76dcc6c nandi 11d ago468 # frqScript. just so the recipe runner comes from here too rather
469 # than the host — `nix develop` and then `just run` is the whole of
470 # what a machine with nix needs.
471 packages = [ jolt pkgs.just (nixGLFor pkgs) ];
472
473 # Read by the recipes rather than baked into a wrapper: the frq
Run this tree on a native half the builders made a32699e nandi 17d ago474 # source `just run` runs is the working tree, so the launcher has
Inline the babashka scripts into the justfile 76dcc6c nandi 11d ago475 # to live in that tree and the shell has to hand it its answers.
476 # Naming these is also what makes the shell build them.
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago477 JOLT_NATIVE_LIB = "${nativeAll}/lib";
Run this tree on a native half the builders made a32699e nandi 17d ago478 GLIMMER_SRC = glimmer;
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago479 GLIMMER_VIDYA_SRC = "${jolt-native}/glimmer-backends/glimmer-vidya";
480 GLIMMER_TUI_SRC = "${jolt-native}/glimmer-backends/glimmer-tui";
Run this tree on a native half the builders made a32699e nandi 17d ago481 FRQ_LIB_PATH = lib.makeLibraryPath (runtimeLibsFor pkgs);
482 NIXGL = "${nixGLFor pkgs}/bin/nixGLIntel";
483 };
484 });
485
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago486 apps = forEachSystem (pkgs: {
487 default = {
488 type = "app";
489 program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.frq}/bin/frq";
490 };
Paint the same screens into a terminal ab83b42 nandi 17d ago491 tui = {
492 type = "app";
493 program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.tui}/bin/frq-tui";
494 };
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago495 });
496 };
497}