| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 1 | { |
| 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 ago | 16 | # 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 ago | 20 | 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 ago | 24 | # `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 ago | 36 | jolt-src = { |
| Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago | 37 | 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 ago | 39 | }; |
| 40 | |
| Build the desktop libraries rather than fetching a release of them 0b81161 nandi 15d ago | 41 | # Ahead of v0.1.3, which is what nix/android.nix pins the APK to — and |
| 42 | # deliberately: that pin is the last release, and this is what `just run` |
| 43 | # builds, so a change to jolt-native can be run before there is a release |
| 44 | # to fetch. The two meet again at `just bump`. |
| Take the jolt-native ahead of the release, since a run can build it 36f6c77 nandi 17d ago | 45 | # |
| 46 | # 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 ago | 47 | # glimmer-vidya — libvidya, and the Jolt side that binds it — so an |
| 48 | # unpinned `main` is a build whose native half is free to sit at a |
| 49 | # different commit from the tree that talks to it. It did, and what the |
| 50 | # drift cost was silence: the Jolt half sent a reaction pill's hover card |
| 51 | # 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 ago | 52 | # It also carries the terminal backend — crates/jolt-tui, the same tree ABI |
| 53 | # over a grid of cells, and jolt/glimmer-tui beside glimmer-vidya. That was |
| 54 | # a second input at a second rev while it lived on a branch, which is the |
| 55 | # drift this comment warns about wearing a different hat: one input, and |
| 56 | # 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 ago | 57 | jolt-native = { |
| Take jolt and jolt-native as flakes, off my own fork aaa560d nandi 13d ago | 58 | url = "git+https://gitlab.com/nandithebull/jolt-native?rev=4956d1e2f73eae7b1f8ef16fab875c56c69dea84"; |
| 59 | inputs.nixpkgs.follows = "nixpkgs"; |
| Paint the same screens into a terminal ab83b42 nandi 17d ago | 60 | }; |
| 61 | |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 62 | # Chez itself, because the APK needs a cross target nixpkgs does not |
| 63 | # build: frq's Scheme is compiled to an arm64 boot image, and that wants |
| 64 | # Chez's own `tarm64le` workarea — boot files, xpatch and libkernel.a. |
| 65 | # The version is the one the hand-built tree under ~/.cache used, and the |
| 66 | # 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 ago | 67 | # The same fork jolt-src takes, built here rather than fetched as a |
| 68 | # release binary: upstream reads the socket address out of `struct |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 69 | # 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 ago | 70 | # built with upstream cannot open a TLS connection at all. Pinned to a rev |
| 71 | # where jolt-src is not: the APK is a release artefact, so its runtime |
| 72 | # moves when `just bump` says so rather than when the fork does. |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 73 | jolt-android-src = { |
| 74 | 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 ago | 75 | inputs.nixpkgs.follows = "nixpkgs"; |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 76 | }; |
| 77 | |
| 78 | chez-src = { |
| 79 | url = "git+https://github.com/cisco/ChezScheme?ref=refs/tags/v10.4.1&submodules=1"; |
| 80 | flake = false; |
| 81 | }; |
| 82 | |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 83 | # The sha deps.edn pins, on the fork with the reconciler fixes. |
| 84 | glimmer = { |
| 85 | url = "git+https://gitlab.com/nandithebull/glimmer?rev=399df371c790d690fb6e4560c3d4d7f838502857"; |
| 86 | flake = false; |
| 87 | }; |
| Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago | 88 | |
| 89 | # Only ever used off NixOS, to put the host GL driver on the loader path. |
| 90 | nixgl = { |
| 91 | url = "github:nix-community/nixGL"; |
| 92 | inputs.nixpkgs.follows = "nixpkgs"; |
| 93 | }; |
| Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago | 94 | |
| 95 | # Wraps a closure into a single self-extracting file. Only the `appimage` |
| 96 | # output evaluates it. |
| 97 | nix-appimage = { |
| 98 | url = "github:ralismark/nix-appimage"; |
| 99 | inputs.nixpkgs.follows = "nixpkgs"; |
| 100 | }; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 101 | }; |
| 102 | |
| Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago | 103 | outputs = { self, nixpkgs, jolt-src, jolt-native, glimmer, chez-src, jolt-android-src, nixgl, nix-appimage }: |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 104 | let |
| 105 | systems = [ "x86_64-linux" "aarch64-linux" ]; |
| 106 | forEachSystem = f: |
| 107 | nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 108 | |
| 109 | # Mesa, despite the name: it covers Intel and AMD alike. The NVIDIA |
| 110 | # wrappers are the ones that need --impure (they read the host kernel |
| 111 | # 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 ago | 112 | # |
| 113 | # Built from nixGL's default.nix rather than taken from its flake |
| 114 | # outputs, for the one argument the flake hardcodes on: `enable32bits`, |
| 115 | # which on x86_64 puts a second, i686 copy of mesa, its LLVM, and |
| 116 | # intel-media-driver into the wrapper. frq is 64-bit on both halves — |
| 117 | # the Rust cdylibs and the Chez runtime — so nothing here ever opens the |
| 118 | # 32-bit driver, and carrying it is most of the dev shell's closure. |
| 119 | nixGLFor = pkgs: (import nixgl { |
| 120 | inherit pkgs; |
| 121 | enable32bits = false; |
| 122 | }).nixGLIntel; |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 123 | |
| 124 | # egui reaches for these with dlopen rather than linking them, so being |
| 125 | # 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 ago | 126 | # 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 ago | 127 | # "X11 unavailable", falls back to Wayland, and winit refuses to build a |
| 128 | # second event loop after the failed first one. |
| 129 | # |
| 130 | # Out here rather than beside the package that first needed them: the |
| 131 | # dev shell starts frq too, on this tree's source rather than the store's |
| 132 | # copy of it, and a second copy of this list is a second chance for the |
| 133 | # two ways of running to disagree about what the window needs. |
| 134 | runtimeLibsFor = pkgs: with pkgs; [ |
| 135 | libGL |
| 136 | libxkbcommon |
| 137 | wayland |
| Follow the xorg renames, and stop wrapping nix in distrobox a400a00 nandi 16d ago | 138 | libx11 |
| 139 | libxcursor |
| 140 | libxi |
| 141 | libxrandr |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 142 | vulkan-loader |
| 143 | ]; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 144 | in |
| 145 | { |
| 146 | packages = forEachSystem (pkgs: |
| 147 | let |
| 148 | inherit (pkgs) lib; |
| 149 | |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 150 | nixGL = nixGLFor pkgs; |
| Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago | 151 | |
| Take the native objects from their own flake rather than rebuilding them 0ee8bba nandi 13d ago | 152 | # libvidya (the retained-tree ABI glimmer-vidya binds, on egui), |
| 153 | # libjolttui (the same tree over a grid of cells) and libjoltmoq (the |
| 154 | # AV media plane) — one workspace, three cdylibs, taken from |
| 155 | # jolt-native's own flake rather than rebuilt here. |
| 156 | # |
| 157 | # This used to be a rustPlatform.buildRustPackage over the same |
| 158 | # source, which meant restating upstream's build: the seven git deps |
| 159 | # hashed by hand in `cargoLock.outputHashes` and re-hashed whenever |
| 160 | # its Cargo.lock moved, the linuxHeaders path v4l2r's bindgen wants, |
| 161 | # and a postPatch dropping the .cargo/config.toml that pointed the |
| 162 | # build at DotSlash. Upstream's flake says all of that itself now, |
| 163 | # and says it once. It also builds cpal with the `pipewire` feature, |
| 164 | # which the restatement did not — so device names in a call are |
| 165 | # PipeWire's rather than raw ALSA PCMs. |
| 166 | native = jolt-native.packages.${pkgs.stdenv.hostPlatform.system}.default; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 167 | |
| 168 | # 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 ago | 169 | # A function, because there are two of them — upstream for the |
| 170 | # desktop, and the Bionic-addrinfo fork for the boot image the APK |
| 171 | # carries. Nothing else about the build differs. |
| 172 | joltFrom = src: pkgs.stdenv.mkDerivation { |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 173 | pname = "jolt"; |
| 174 | version = "dev"; |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 175 | inherit src; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 176 | |
| 177 | strictDeps = true; |
| 178 | nativeBuildInputs = with pkgs; [ chez makeWrapper pkg-config xxd ]; |
| 179 | buildInputs = with pkgs; [ lz4 zlib ncurses openssl libuuid ]; |
| 180 | |
| 181 | JOLT_VERSION = "dev"; |
| 182 | dontConfigure = true; |
| 183 | |
| 184 | buildPhase = '' |
| 185 | runHook preBuild |
| 186 | scheme --script host/chez/build-jolt.ss release target/release/jolt |
| 187 | runHook postBuild |
| 188 | ''; |
| 189 | |
| 190 | installPhase = '' |
| 191 | runHook preInstall |
| 192 | mkdir -p "$out/bin" |
| 193 | install -m755 target/release/jolt "$out/bin/jolt" |
| 194 | runHook postInstall |
| 195 | ''; |
| 196 | |
| 197 | # 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 ago | 198 | # OpenSSL through the JOLT_OPENSSL_LIBDIR seam. gitMinimal rather |
| 199 | # than git: all jolt.deps asks for is clone/fetch/rev-parse, and |
| 200 | # the full package carries Perl and Python for the subcommands |
| 201 | # 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 ago | 202 | # |
| 203 | # TZDIR so a zone *name* resolves wherever this runs: frq.clock |
| 204 | # hands one to tzset, and glibc then looks for the tzfile under |
| 205 | # /usr/share/zoneinfo unless told otherwise — which a NixOS host |
| 206 | # does not have. The store's own tzdata is there on both kinds of |
| 207 | # 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 ago | 208 | postFixup = '' |
| 209 | wrapProgram "$out/bin/jolt" \ |
| Stop carrying the 32-bit GL stack and half of git 040f2c1 nandi 16d ago | 210 | --prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.gitMinimal pkgs.unzip ]}" \ |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 211 | --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 ago | 212 | --set-default TZDIR "${pkgs.tzdata}/share/zoneinfo" \ |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 213 | --set-default SSL_CERT_FILE "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" |
| 214 | ''; |
| 215 | }; |
| 216 | |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 217 | joltRuntime = joltFrom jolt-src; |
| 218 | joltAndroid = joltFrom jolt-android-src; |
| 219 | |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 220 | # glimmer-vidya lives inside the jolt-native checkout, and its own |
| 221 | # deps.edn asks for glimmer by git — the top-level override below |
| 222 | # answers for both. |
| 223 | glimmerVidya = "${jolt-native}/jolt/glimmer-vidya"; |
| Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago | 224 | glimmerTui = "${jolt-native}/jolt/glimmer-tui"; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 225 | |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 226 | runtimeLibs = runtimeLibsFor pkgs; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 227 | |
| 228 | # The project as jolt sees it: source, deps.edn, nothing else. |
| 229 | frqSource = pkgs.runCommand "frq-source" { } '' |
| 230 | mkdir -p "$out" |
| 231 | cp -r ${self}/src ${self}/deps.edn "$out/" |
| 232 | ''; |
| 233 | |
| 234 | # Jolt resolves deps.edn from the working directory, so the launcher |
| 235 | # runs from the store copy. Its .jolt/cpcache write lands on a |
| 236 | # read-only directory and jolt treats that as a quiet cache miss, so |
| 237 | # the only cost is re-resolving the (already local) graph per start. |
| 238 | frqScript = pkgs.writeShellScript "frq" '' |
| 239 | export LD_LIBRARY_PATH="${native}/lib:${lib.makeLibraryPath runtimeLibs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
| 240 | cd ${frqSource} |
| Find the host's GL driver when the store's is not the system's 633faad nandi 19d ago | 241 | |
| 242 | # On NixOS the store's Mesa is the system's and the window opens. |
| 243 | # Anywhere else the real driver is the host's, so defer to nixGL — |
| 244 | # it prepends the host driver, which has to win over ours. |
| 245 | runner="" |
| 246 | [ -e /run/current-system ] || runner="${nixGL}/bin/nixGLIntel" |
| 247 | |
| 248 | exec ''${runner} ${joltRuntime}/bin/jolt \ |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 249 | -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"}}}' \ |
| 250 | -M:frq "$@" |
| 251 | ''; |
| 252 | |
| Paint the same screens into a terminal ab83b42 nandi 17d ago | 253 | # The same source, the other backend. No GL, no nixGL and no X11 — |
| 254 | # a terminal is the one surface that needs nothing from the host but |
| 255 | # a terminal, which is the reason this output exists. |
| 256 | tuiScript = pkgs.writeShellScript "frq-tui" '' |
| Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago | 257 | export LD_LIBRARY_PATH="${native}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
| Paint the same screens into a terminal ab83b42 nandi 17d ago | 258 | cd ${frqSource} |
| 259 | |
| 260 | exec ${joltRuntime}/bin/jolt \ |
| 261 | -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"} nandi/glimmer-tui {:local/root "${glimmerTui}"}}}' \ |
| 262 | -m frq.tui "$@" |
| 263 | ''; |
| 264 | |
| 265 | tui = pkgs.runCommand "frq-tui-0.1.0" |
| 266 | { |
| 267 | meta = { |
| 268 | description = "frq's screens in a terminal"; |
| 269 | mainProgram = "frq-tui"; |
| 270 | platforms = systems; |
| 271 | }; |
| 272 | } |
| 273 | '' |
| 274 | mkdir -p "$out/bin" |
| 275 | ln -s ${tuiScript} "$out/bin/frq-tui" |
| 276 | ''; |
| 277 | |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 278 | frq = pkgs.runCommand "frq-0.1.0" |
| 279 | { |
| 280 | meta = { |
| 281 | description = "A freeq client in jolt"; |
| 282 | mainProgram = "frq"; |
| 283 | platforms = systems; |
| 284 | }; |
| 285 | } |
| 286 | '' |
| 287 | mkdir -p "$out/bin" |
| 288 | ln -s ${frqScript} "$out/bin/frq" |
| 289 | ''; |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 290 | # --- Android ------------------------------------------------------ |
| 291 | # The SDK and the NDK are Google's, which means unfree and a licence |
| 292 | # to accept — so this is its own import of nixpkgs rather than the |
| 293 | # `legacyPackages` everything above uses. Confined to the Android |
| 294 | # outputs: `nix build` of frq itself never evaluates it. |
| 295 | # |
| Build the APK as derivations only, and retire the buck2 graph 3bc3aaa nandi 16d ago | 296 | # The NDK here is r29, which is the one the pinned libvidya was |
| 297 | # built with. |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 298 | androidPkgs = import nixpkgs { |
| 299 | inherit (pkgs.stdenv.hostPlatform) system; |
| 300 | config = { |
| 301 | allowUnfree = true; |
| 302 | android_sdk.accept_license = true; |
| 303 | }; |
| 304 | }; |
| 305 | |
| 306 | androidComposition = androidPkgs.androidenv.composeAndroidPackages { |
| 307 | buildToolsVersions = [ "36.0.0" ]; |
| 308 | platformVersions = [ "36" ]; |
| 309 | includeNDK = true; |
| 310 | }; |
| 311 | |
| 312 | android = import ./nix/android.nix { |
| 313 | inherit pkgs self chez-src jolt-native glimmer joltAndroid; |
| 314 | inherit (pkgs) lib; |
| 315 | androidSdk = androidComposition.androidsdk; |
| 316 | ndk = androidComposition.ndk-bundle; |
| 317 | }; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 318 | in |
| 319 | { |
| 320 | inherit native frq; |
| Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago | 321 | inherit tui; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 322 | jolt = joltRuntime; |
| 323 | default = frq; |
| Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago | 324 | |
| Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago | 325 | # The interpreter scripts/ is written in, named here so that |
| 326 | # scripts/bb can build it. Nothing else in this flake uses it: it is |
| 327 | # an output because a shell script cannot ask for `nixpkgs#babashka` |
| 328 | # at the version this tree pins, and `.#bb` is exactly that. |
| 329 | bb = pkgs.babashka; |
| 330 | |
| Bundle the closure into one file the AppImage runtime mounts f82b93f nandi 18d ago | 331 | # frq and everything it loads, squashed into one runnable file for |
| 332 | # hosts without Nix. The whole closure rides along — Mesa included, |
| 333 | # which is not waste: off NixOS the launcher goes through nixGL, and |
| 334 | # nixGL needs a store Mesa to put the host's driver in front of. |
| 335 | appimage = |
| 336 | nix-appimage.bundlers.${pkgs.stdenv.hostPlatform.system}.default frq; |
| Build the APK from the flake, and from nothing 6aa2a6b nandi 18d ago | 337 | } |
| 338 | # An APK is built by a linux-x86_64 NDK and a linux-x86_64 jolt, and |
| 339 | # Google ships no other; on aarch64 the Android outputs are simply |
| 340 | # absent rather than present and broken. |
| 341 | // lib.optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") { |
| 342 | inherit (android) apk chezAndroid joltBoot libjoltapp; |
| 343 | apk-unsigned = android.apk-unsigned; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 344 | }); |
| 345 | |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 346 | # Where `just run` runs, and — because entering it realises what it |
| 347 | # names — what builds the half of frq that is not this working tree. |
| 348 | # |
| 349 | # The two halves, and the split is the whole point of the shell. The frq |
| 350 | # source is the files on disk, uncommitted edits and all. Everything |
| 351 | # under it — jolt, glimmer, glimmer-vidya, both native objects — is the |
| 352 | # flake's, at the revs flake.lock names, so a run says what it ran |
| 353 | # against and both halves of glimmer-vidya move together. That is the |
| 354 | # drift the `jolt-native` input's comment is about, and a pin frq can |
| 355 | # answer for is worth more here than the convenience of a checkout. |
| 356 | # |
| Take the native objects from their own flake rather than rebuilding them 0ee8bba nandi 13d ago | 357 | # `native` is jolt-native's own flake output. It was a buck2 graph when |
| 358 | # this comment was first written and a cargo build restated here when it |
| 359 | # was second: buck2 fetches its rustc, zig and every third-party crate as |
| 360 | # it goes and writes buck-out into the tree it builds, so a sandbox with |
| 361 | # no network and a read-only store was the one place it could not run. |
| 362 | # Upstream builds with nix now, so the thing its CI runs and the thing |
| 363 | # this shell hands a builder are the same derivation. |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 364 | # |
| 365 | # Nothing here says "nixbuild", though: it is a plain derivation, and |
| 366 | # where it gets built is the machine's business. scripts/run.bb asks for |
| 367 | # the shell with --max-jobs 0, which is what sends it to the `builders` |
| 368 | # entry rather than compiling egui on a laptop. |
| 369 | devShells = forEachSystem (pkgs: |
| 370 | let |
| 371 | inherit (pkgs) lib; |
| 372 | inherit (self.packages.${pkgs.stdenv.hostPlatform.system}) jolt native; |
| 373 | in |
| 374 | { |
| 375 | default = pkgs.mkShellNoCC { |
| 376 | name = "frq"; |
| 377 | |
| 378 | # jolt, because the runtime frq is run by should be the flake's |
| 379 | # too. nixGL for the same reason the launcher reaches for it — see |
| Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago | 380 | # frqScript. babashka because scripts/bb prefers one on PATH, and |
| 381 | # inside here that should be this one rather than a second copy |
| Take just from the dev shell, so the host needs no copy of it 9afdfa4 nandi 16d ago | 382 | # built through `.#bb`. just so the recipe runner comes from here |
| 383 | # too rather than the host — `nix develop` and then `just run` is |
| 384 | # the whole of what a machine with nix needs. |
| 385 | packages = [ jolt pkgs.babashka pkgs.just (nixGLFor pkgs) ]; |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 386 | |
| 387 | # Read by scripts/run.bb rather than baked into a wrapper: the frq |
| 388 | # source `just run` runs is the working tree, so the launcher has |
| 389 | # to be a script in that tree and the shell has to hand it its |
| 390 | # answers. Naming these is also what makes the shell build them. |
| 391 | JOLT_NATIVE_LIB = "${native}/lib"; |
| 392 | GLIMMER_SRC = glimmer; |
| 393 | GLIMMER_VIDYA_SRC = "${jolt-native}/jolt/glimmer-vidya"; |
| Merge origin/main, and let one jolt-native answer for both backends 1e8b590 nandi 16d ago | 394 | GLIMMER_TUI_SRC = "${jolt-native}/jolt/glimmer-tui"; |
| Run this tree on a native half the builders made a32699e nandi 17d ago | 395 | FRQ_LIB_PATH = lib.makeLibraryPath (runtimeLibsFor pkgs); |
| 396 | NIXGL = "${nixGLFor pkgs}/bin/nixGLIntel"; |
| 397 | }; |
| 398 | }); |
| 399 | |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 400 | apps = forEachSystem (pkgs: { |
| 401 | default = { |
| 402 | type = "app"; |
| 403 | program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.frq}/bin/frq"; |
| 404 | }; |
| Paint the same screens into a terminal ab83b42 nandi 17d ago | 405 | tui = { |
| 406 | type = "app"; |
| 407 | program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.tui}/bin/frq-tui"; |
| 408 | }; |
| Build the client with Nix, not just a shell for it ca3afbe nandi 19d ago | 409 | }); |
| 410 | }; |
| 411 | } |