nandi/frqpublic Fork 0
596dc29918234b30998f1f9406391ae6b4b3bfc0
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 · 538 lines · 25.8 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
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago63 # The Android objects, prebuilt by jolt-native's CI rather than compiled
64 # here: an APK needs libvidya and libjoltmoq for arm64, and building them
65 # locally means an NDK, a Rust cross toolchain and the whole crane graph
66 # for two files that upstream already built and published.
67 #
68 # "latest" is the version its CI overwrites on every default-branch build,
69 # so this input finds a new one on `nix flake update` -- but flake.lock
70 # still records exactly which bytes an APK was built from, which is the
71 # pin that matters. `just bump` decides when to move; this only decides
72 # where to look. The archive is rooted at include/ and lib/arm64-v8a/, so
73 # nothing here has to unpack it.
74 jolt-native-android = {
75 url = "https://gitlab.com/api/v4/projects/nandithebull%2Fjolt-native/packages/generic/jolt-native/latest/android-arm64-v8a.tar.gz";
76 flake = false;
77 };
78
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago79 # Chez itself, because the APK needs a cross target nixpkgs does not
80 # build: frq's Scheme is compiled to an arm64 boot image, and that wants
81 # Chez's own `tarm64le` workarea — boot files, xpatch and libkernel.a.
82 # The version is the one the hand-built tree under ~/.cache used, and the
83 # 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 ago84 # The same fork jolt-src takes, built here rather than fetched as a
85 # release binary: upstream reads the socket address out of `struct
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago86 # 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 ago87 # built with upstream cannot open a TLS connection at all. Pinned to a rev
88 # where jolt-src is not: the APK is a release artefact, so its runtime
89 # moves when `just bump` says so rather than when the fork does.
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago90 jolt-android-src = {
91 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 ago92 inputs.nixpkgs.follows = "nixpkgs";
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago93 };
94
95 chez-src = {
96 url = "git+https://github.com/cisco/ChezScheme?ref=refs/tags/v10.4.1&submodules=1";
97 flake = false;
98 };
99
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago100 # The sha deps.edn pins, on the fork with the reconciler fixes.
101 glimmer = {
102 url = "git+https://gitlab.com/nandithebull/glimmer?rev=399df371c790d690fb6e4560c3d4d7f838502857";
103 flake = false;
104 };
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago105
106 # Only ever used off NixOS, to put the host GL driver on the loader path.
107 nixgl = {
108 url = "github:nix-community/nixGL";
109 inputs.nixpkgs.follows = "nixpkgs";
110 };
Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago111
112 # Wraps a closure into a single self-extracting file. Only the `appimage`
113 # output evaluates it.
114 nix-appimage = {
115 url = "github:ralismark/nix-appimage";
116 inputs.nixpkgs.follows = "nixpkgs";
117 };
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago118 };
119
Fetch libmoq_ffi again, and keep the codecs out of Rust f518938 nandi 9d ago120 outputs = { self, nixpkgs, jolt-src, jolt-native, jolt-native-android, glimmer, chez-src, jolt-android-src, nixgl, nix-appimage }:
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago121 let
122 systems = [ "x86_64-linux" "aarch64-linux" ];
123 forEachSystem = f:
124 nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
Run this tree on a native half the builders made a32699e nandi 17d ago125
126 # Mesa, despite the name: it covers Intel and AMD alike. The NVIDIA
127 # wrappers are the ones that need --impure (they read the host kernel
128 # 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 ago129 #
130 # Built from nixGL's default.nix rather than taken from its flake
131 # outputs, for the one argument the flake hardcodes on: `enable32bits`,
132 # which on x86_64 puts a second, i686 copy of mesa, its LLVM, and
133 # intel-media-driver into the wrapper. frq is 64-bit on both halves —
134 # the Rust cdylibs and the Chez runtime — so nothing here ever opens the
135 # 32-bit driver, and carrying it is most of the dev shell's closure.
136 nixGLFor = pkgs: (import nixgl {
137 inherit pkgs;
138 enable32bits = false;
139 }).nixGLIntel;
Run this tree on a native half the builders made a32699e nandi 17d ago140
141 # egui reaches for these with dlopen rather than linking them, so being
142 # 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 ago143 # 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 ago144 # "X11 unavailable", falls back to Wayland, and winit refuses to build a
145 # second event loop after the failed first one.
146 #
147 # Out here rather than beside the package that first needed them: the
148 # dev shell starts frq too, on this tree's source rather than the store's
149 # copy of it, and a second copy of this list is a second chance for the
150 # two ways of running to disagree about what the window needs.
151 runtimeLibsFor = pkgs: with pkgs; [
152 libGL
153 libxkbcommon
154 wayland
Follow the xorg renames, and stop wrapping nix in distrobox a400a00 nandi 16d ago155 libx11
156 libxcursor
157 libxi
158 libxrandr
Run this tree on a native half the builders made a32699e nandi 17d ago159 vulkan-loader
160 ];
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago161 in
162 {
163 packages = forEachSystem (pkgs:
164 let
165 inherit (pkgs) lib;
166
Run this tree on a native half the builders made a32699e nandi 17d ago167 nixGL = nixGLFor pkgs;
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago168
Take the native objects from their own flake rather than rebuilding them 0ee8bba nandi 13d ago169 # libvidya (the retained-tree ABI glimmer-vidya binds, on egui),
170 # libjolttui (the same tree over a grid of cells) and libjoltmoq (the
171 # AV media plane) — one workspace, three cdylibs, taken from
172 # jolt-native's own flake rather than rebuilt here.
173 #
174 # This used to be a rustPlatform.buildRustPackage over the same
175 # source, which meant restating upstream's build: the seven git deps
176 # hashed by hand in `cargoLock.outputHashes` and re-hashed whenever
177 # its Cargo.lock moved, the linuxHeaders path v4l2r's bindgen wants,
178 # and a postPatch dropping the .cargo/config.toml that pointed the
179 # build at DotSlash. Upstream's flake says all of that itself now,
180 # and says it once. It also builds cpal with the `pipewire` feature,
181 # which the restatement did not — so device names in a call are
182 # PipeWire's rather than raw ALSA PCMs.
183 native = jolt-native.packages.${pkgs.stdenv.hostPlatform.system}.default;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago184
Fetch libmoq_ffi again, and keep the codecs out of Rust f518938 nandi 9d ago185 # libmoq_ffi — MoQ over QUIC behind UniFFI's C ABI, FETCHED rather
186 # than built. 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 ago187 #
Fetch libmoq_ffi again, and keep the codecs out of Rust f518938 nandi 9d ago188 # Fetched because building it is the thing this whole exercise is
189 # about: moq-ffi pulls moq-native, iroh, quinn, rustls and aws-lc-sys
190 # behind it, which is 440 crates that nothing else in this tree
191 # needs. Upstream already publishes the object for both Linux
192 # architectures, so we take those bytes.
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago193 #
Fetch libmoq_ffi again, and keep the codecs out of Rust f518938 nandi 9d ago194 # Pinned to a release and to a hash, and the hashes below are
195 # upstream's own published .sha256 files rather than ones observed
196 # here — a `nix-prefetch` of whatever the URL serves today would
197 # record that it downloaded something, not that it downloaded the
198 # right thing.
199 #
200 # WHAT THIS BUILD IS NOT: moq-ffi's `audio` and `video` features are
201 # on by default upstream and are OFF in these artifacts, so there is
202 # no publish_audio/publish_video and no moqaudio*/moqvideo* here —
203 # 206 functions where the Apple artifact has 230. That is why the
204 # bindings are generated from the object (`just gen-moq`) and not
205 # from the C header the release ships, which describes the Apple one.
206 moqFfi =
207 let
208 version = "0.3.17";
209 target = {
210 "x86_64-linux" = "x86_64-unknown-linux-gnu";
211 "aarch64-linux" = "aarch64-unknown-linux-gnu";
212 }.${pkgs.stdenv.hostPlatform.system};
213 hash = {
214 "x86_64-linux" = "sha256-dzQXpV4JgdtD+g33WX51FFAQdfCUXkNsx1xPbobPfUI=";
215 "aarch64-linux" = "sha256-PdzRwbJFqOZWRgI0HHX2XUH+Ljh4V3jvQ9asfvCuIPA=";
216 }.${pkgs.stdenv.hostPlatform.system};
217 in
218 pkgs.stdenv.mkDerivation {
219 pname = "libmoq-ffi";
220 inherit version;
221 src = pkgs.fetchurl {
222 url = "https://github.com/kixelated/moq/releases/download/moq-ffi-v${version}/moq-ffi-${version}-${target}-libmoq_ffi.so";
223 inherit hash;
224 };
225 dontUnpack = true;
226 # It carries no RUNPATH and needs libgcc_s, libm and libc — the
227 # host's on an ordinary distro, and nothing at all on NixOS
228 # unless they are bound here.
229 nativeBuildInputs = [ pkgs.autoPatchelfHook ];
230 buildInputs = [ pkgs.stdenv.cc.cc.lib ];
231 installPhase = ''
232 mkdir -p $out/lib
233 cp $src $out/lib/libmoq_ffi.so
234 chmod +w $out/lib/libmoq_ffi.so
235 '';
236 };
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago237
238 # One directory for the loader to look in. jolt resolves every
239 # :jolt/native name against JOLT_NATIVE_LIB, and the objects now come
240 # from two places — jolt-native's flake, and the moq-ffi release — so
241 # they are joined rather than the path being made a list, which the
242 # loader does not take.
Bind the C libraries a call actually needs 87e5be9 nandi 9d ago243 # The C codecs, from nixpkgs. libmoq_ffi carries the transport and
244 # nothing else — moq-ffi's `audio` and `video` features would have
245 # brought Opus and H.264 with them, at the price of compiling a
246 # 1062-crate workspace — so the codecs are linked here instead,
247 # where they have always lived.
248 #
249 # Named in :jolt/native, so the loader resolves them the same way it
250 # resolves libvidya: by name, out of one directory.
251 # A flat C face for openh264, because openh264 has none. Its
252 # `ISVCEncoder` is `const ISVCEncoderVtbl*` — every method is a
253 # function pointer in a vtable — and jolt.ffi cannot call one: Chez
254 # fixes a foreign procedure's types when it compiles it, and the
255 # target must be a literal C symbol name. So the vtable is walked in
256 # c/frq_h264.c and jolt binds the five plain symbols it exports.
257 #
258 # One translation unit against a library nixpkgs already has. It is
259 # a calling convention adapter, not a second media plane, and the
260 # distinction from the moq-ffi build it replaces is the whole point:
261 # this compiles one .c file, not a 1062-crate workspace.
262 frqH264 = pkgs.stdenv.mkDerivation {
263 pname = "frq-h264";
264 version = "0.1";
265 src = ./c;
266 nativeBuildInputs = [ pkgs.pkg-config ];
267 buildInputs = [ pkgs.openh264 ];
268 buildPhase = ''
269 $CC -O2 -fPIC -shared frq_h264.c -o libfrqh264.so \
270 $(pkg-config --cflags --libs openh264)
271 '';
272 installPhase = ''
273 mkdir -p $out/lib && cp libfrqh264.so $out/lib/
274 '';
275 };
276
277 # openh264 is here for frqH264's DT_NEEDED; alsa-lib for capture
278 # and playback. V4L2 needs nothing: it is ioctls against libc and
279 # the kernel, so there is no library to name.
280 codecs = [ pkgs.libopus pkgs.openh264 frqH264 pkgs.alsa-lib ];
281
Let the plane take real devices, not only test thunks 596dc29 nandi 9d ago282 # ALSA's PipeWire plugin, which is how `default` resolves to
283 # anything on a machine running PipeWire — and every machine frq
284 # targets does. Without it alsa-lib fails to dlopen
285 # libasound_module_pcm_pipewire.so and the only devices that open
286 # are raw hardware ones, which PipeWire is already holding.
287 #
288 # An environment variable rather than a library in the join:
289 # alsa-lib looks plugins up by directory, not by soname.
290 alsaPluginDir = "${pkgs.pipewire}/lib/alsa-lib";
291
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago292 nativeAll = pkgs.symlinkJoin {
293 name = "frq-native";
Bind the C libraries a call actually needs 87e5be9 nandi 9d ago294 paths = [ native moqFfi ] ++ codecs;
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago295 };
296
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago297 # 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 ago298 # A function, because there are two of them — upstream for the
299 # desktop, and the Bionic-addrinfo fork for the boot image the APK
300 # carries. Nothing else about the build differs.
301 joltFrom = src: pkgs.stdenv.mkDerivation {
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago302 pname = "jolt";
303 version = "dev";
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago304 inherit src;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago305
306 strictDeps = true;
307 nativeBuildInputs = with pkgs; [ chez makeWrapper pkg-config xxd ];
308 buildInputs = with pkgs; [ lz4 zlib ncurses openssl libuuid ];
309
310 JOLT_VERSION = "dev";
311 dontConfigure = true;
312
313 buildPhase = ''
314 runHook preBuild
315 scheme --script host/chez/build-jolt.ss release target/release/jolt
316 runHook postBuild
317 '';
318
319 installPhase = ''
320 runHook preInstall
321 mkdir -p "$out/bin"
322 install -m755 target/release/jolt "$out/bin/jolt"
323 runHook postInstall
324 '';
325
326 # 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 ago327 # OpenSSL through the JOLT_OPENSSL_LIBDIR seam. gitMinimal rather
328 # than git: all jolt.deps asks for is clone/fetch/rev-parse, and
329 # the full package carries Perl and Python for the subcommands
330 # 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 ago331 #
332 # TZDIR so a zone *name* resolves wherever this runs: frq.clock
333 # hands one to tzset, and glibc then looks for the tzfile under
334 # /usr/share/zoneinfo unless told otherwise — which a NixOS host
335 # does not have. The store's own tzdata is there on both kinds of
336 # 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 ago337 postFixup = ''
338 wrapProgram "$out/bin/jolt" \
Stop carrying the 32-bit GL stack and half of git 040f2c1 nandi 16d ago339 --prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.gitMinimal pkgs.unzip ]}" \
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago340 --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 ago341 --set-default TZDIR "${pkgs.tzdata}/share/zoneinfo" \
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago342 --set-default SSL_CERT_FILE "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
343 '';
344 };
345
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago346 joltRuntime = joltFrom jolt-src;
347 joltAndroid = joltFrom jolt-android-src;
348
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago349 # glimmer-vidya lives inside the jolt-native checkout, and its own
350 # deps.edn asks for glimmer by git — the top-level override below
351 # answers for both.
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago352 glimmerVidya = "${jolt-native}/glimmer-backends/glimmer-vidya";
353 glimmerTui = "${jolt-native}/glimmer-backends/glimmer-tui";
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago354
Run this tree on a native half the builders made a32699e nandi 17d ago355 runtimeLibs = runtimeLibsFor pkgs;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago356
357 # The project as jolt sees it: source, deps.edn, nothing else.
358 frqSource = pkgs.runCommand "frq-source" { } ''
359 mkdir -p "$out"
360 cp -r ${self}/src ${self}/deps.edn "$out/"
361 '';
362
363 # Jolt resolves deps.edn from the working directory, so the launcher
364 # runs from the store copy. Its .jolt/cpcache write lands on a
365 # read-only directory and jolt treats that as a quiet cache miss, so
366 # the only cost is re-resolving the (already local) graph per start.
367 frqScript = pkgs.writeShellScript "frq" ''
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago368 export LD_LIBRARY_PATH="${nativeAll}/lib:${lib.makeLibraryPath runtimeLibs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
Let the plane take real devices, not only test thunks 596dc29 nandi 9d ago369 export ALSA_PLUGIN_DIR="${alsaPluginDir}"
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago370 cd ${frqSource}
Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago371
372 # On NixOS the store's Mesa is the system's and the window opens.
373 # Anywhere else the real driver is the host's, so defer to nixGL
374 # it prepends the host driver, which has to win over ours.
375 runner=""
376 [ -e /run/current-system ] || runner="${nixGL}/bin/nixGLIntel"
377
378 exec ''${runner} ${joltRuntime}/bin/jolt \
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago379 -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"}}}' \
380 -M:frq "$@"
381 '';
382
Paint the same screens into a terminal ab83b42 nandi 17d ago383 # The same source, the other backend. No GL, no nixGL and no X11 —
384 # a terminal is the one surface that needs nothing from the host but
385 # a terminal, which is the reason this output exists.
386 tuiScript = pkgs.writeShellScript "frq-tui" ''
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago387 export LD_LIBRARY_PATH="${nativeAll}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
Let the plane take real devices, not only test thunks 596dc29 nandi 9d ago388 export ALSA_PLUGIN_DIR="${alsaPluginDir}"
Paint the same screens into a terminal ab83b42 nandi 17d ago389 cd ${frqSource}
390
391 exec ${joltRuntime}/bin/jolt \
392 -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"} nandi/glimmer-tui {:local/root "${glimmerTui}"}}}' \
393 -m frq.tui "$@"
394 '';
395
396 tui = pkgs.runCommand "frq-tui-0.1.0"
397 {
398 meta = {
399 description = "frq's screens in a terminal";
400 mainProgram = "frq-tui";
401 platforms = systems;
402 };
403 }
404 ''
405 mkdir -p "$out/bin"
406 ln -s ${tuiScript} "$out/bin/frq-tui"
407 '';
408
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago409 frq = pkgs.runCommand "frq-0.1.0"
410 {
411 meta = {
412 description = "A freeq client in jolt";
413 mainProgram = "frq";
414 platforms = systems;
415 };
416 }
417 ''
418 mkdir -p "$out/bin"
419 ln -s ${frqScript} "$out/bin/frq"
420 '';
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago421 # --- Android ------------------------------------------------------
422 # The SDK and the NDK are Google's, which means unfree and a licence
423 # to accept — so this is its own import of nixpkgs rather than the
424 # `legacyPackages` everything above uses. Confined to the Android
425 # outputs: `nix build` of frq itself never evaluates it.
426 #
Build the APK as derivations only, and retire the buck2 graph 3bc3aaa nandi 16d ago427 # The NDK here is r29, which is the one the pinned libvidya was
428 # built with.
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago429 androidPkgs = import nixpkgs {
430 inherit (pkgs.stdenv.hostPlatform) system;
431 config = {
432 allowUnfree = true;
433 android_sdk.accept_license = true;
434 };
435 };
436
437 androidComposition = androidPkgs.androidenv.composeAndroidPackages {
438 buildToolsVersions = [ "36.0.0" ];
439 platformVersions = [ "36" ];
440 includeNDK = true;
441 };
442
443 android = import ./nix/android.nix {
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago444 inherit pkgs self chez-src jolt-native jolt-native-android glimmer joltAndroid;
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago445 inherit (pkgs) lib;
446 androidSdk = androidComposition.androidsdk;
447 ndk = androidComposition.ndk-bundle;
448 };
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago449 in
450 {
Bind the C libraries a call actually needs 87e5be9 nandi 9d ago451 inherit native moqFfi frqH264 nativeAll frq;
Let the plane take real devices, not only test thunks 596dc29 nandi 9d ago452 inherit (pkgs) pipewire;
Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago453 inherit tui;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago454 jolt = joltRuntime;
455 default = frq;
Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago456
457 # frq and everything it loads, squashed into one runnable file for
458 # hosts without Nix. The whole closure rides along — Mesa included,
459 # which is not waste: off NixOS the launcher goes through nixGL, and
460 # nixGL needs a store Mesa to put the host's driver in front of.
461 appimage =
462 nix-appimage.bundlers.${pkgs.stdenv.hostPlatform.system}.default frq;
Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago463 }
464 # An APK is built by a linux-x86_64 NDK and a linux-x86_64 jolt, and
465 # Google ships no other; on aarch64 the Android outputs are simply
466 # absent rather than present and broken.
467 // lib.optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") {
468 inherit (android) apk chezAndroid joltBoot libjoltapp;
469 apk-unsigned = android.apk-unsigned;
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago470 });
471
Run this tree on a native half the builders made a32699e nandi 17d ago472 # Where `just run` runs, and — because entering it realises what it
473 # names — what builds the half of frq that is not this working tree.
474 #
475 # The two halves, and the split is the whole point of the shell. The frq
476 # source is the files on disk, uncommitted edits and all. Everything
477 # under it — jolt, glimmer, glimmer-vidya, both native objects — is the
478 # flake's, at the revs flake.lock names, so a run says what it ran
479 # against and both halves of glimmer-vidya move together. That is the
480 # drift the `jolt-native` input's comment is about, and a pin frq can
481 # answer for is worth more here than the convenience of a checkout.
482 #
Take the native objects from their own flake rather than rebuilding them 0ee8bba nandi 13d ago483 # `native` is jolt-native's own flake output. It was a buck2 graph when
484 # this comment was first written and a cargo build restated here when it
485 # was second: buck2 fetches its rustc, zig and every third-party crate as
486 # it goes and writes buck-out into the tree it builds, so a sandbox with
487 # no network and a read-only store was the one place it could not run.
488 # Upstream builds with nix now, so the thing its CI runs and the thing
489 # this shell hands a builder are the same derivation.
Run this tree on a native half the builders made a32699e nandi 17d ago490 #
491 # Nothing here says "nixbuild", though: it is a plain derivation, and
Inline the babashka scripts into the justfile 76dcc6c nandi 11d ago492 # 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 ago493 # the shell with --max-jobs 0, which is what sends it to the `builders`
494 # entry rather than compiling egui on a laptop.
495 devShells = forEachSystem (pkgs:
496 let
497 inherit (pkgs) lib;
Bind libmoq_ffi from the object's own metadata, not from its header 9f081a1 nandi 9d ago498 inherit (self.packages.${pkgs.stdenv.hostPlatform.system}) jolt native nativeAll;
Run this tree on a native half the builders made a32699e nandi 17d ago499 in
500 {
501 default = pkgs.mkShellNoCC {
502 name = "frq";
503
504 # jolt, because the runtime frq is run by should be the flake's
505 # too. nixGL for the same reason the launcher reaches for it — see
Inline the babashka scripts into the justfile 76dcc6c nandi 11d ago506 # frqScript. just so the recipe runner comes from here too rather
507 # than the host — `nix develop` and then `just run` is the whole of
508 # what a machine with nix needs.
509 packages = [ jolt pkgs.just (nixGLFor pkgs) ];
510
511 # 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 ago512 # source `just run` runs is the working tree, so the launcher has
Inline the babashka scripts into the justfile 76dcc6c nandi 11d ago513 # to live in that tree and the shell has to hand it its answers.
514 # 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 ago515 JOLT_NATIVE_LIB = "${nativeAll}/lib";
Let the plane take real devices, not only test thunks 596dc29 nandi 9d ago516 # Spelled out rather than shared with the packages block, which
517 # is a different `let`. See `alsaPluginDir` there for why.
518 ALSA_PLUGIN_DIR = "${pkgs.pipewire}/lib/alsa-lib";
Run this tree on a native half the builders made a32699e nandi 17d ago519 GLIMMER_SRC = glimmer;
Take the Android objects from jolt-native's CI, always the latest 472e179 nandi 11d ago520 GLIMMER_VIDYA_SRC = "${jolt-native}/glimmer-backends/glimmer-vidya";
521 GLIMMER_TUI_SRC = "${jolt-native}/glimmer-backends/glimmer-tui";
Run this tree on a native half the builders made a32699e nandi 17d ago522 FRQ_LIB_PATH = lib.makeLibraryPath (runtimeLibsFor pkgs);
523 NIXGL = "${nixGLFor pkgs}/bin/nixGLIntel";
524 };
525 });
526
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago527 apps = forEachSystem (pkgs: {
528 default = {
529 type = "app";
530 program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.frq}/bin/frq";
531 };
Paint the same screens into a terminal ab83b42 nandi 17d ago532 tui = {
533 type = "app";
534 program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.tui}/bin/frq-tui";
535 };
Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago536 });
537 };
538}