Build libjoltcosmic out of the flake, so frq can link it
crates/jolt-cosmic has been a workspace member for a while and the flake never named it, so the one way to a libjoltcosmic.so was `cargo build --release -p jolt-cosmic` in a checkout — which is what frq's `just cosmic` told you to do, and why frq could run the window from a tree beside it but never from a pin. Its own deps artifact rather than a share of the UI one. libcosmic brings iced, wgpu, cosmic-text and zbus with it, which is the reason the crate is its own crate at all; folding those into the artifact libjolttui waits on would make every terminal build pay for a GPU stack it never loads. `soPackage` grows a `headers` flag for this. It copied crates/<dir>/include unconditionally and jolt-cosmic has no include to copy: the jolt side reaches it through jolt.ffi by symbol name, so there is no C API for an embedder to include a header for. The other three keep the old behaviour, where a header that stops being there fails the build rather than shipping an object with no ABI beside it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
4706c92 parent: 1ee075a modified
flake.nix +26 -3 | @@ -163,6 +163,14 @@ | ||
| 163 | 163 | pname = "jolt-native-moq-deps"; |
| 164 | 164 | packages = [ "jolt-moq" ]; |
| 165 | 165 | }; |
| 166 | + # Its own artifact rather than a share of the UI one, for the reason | |
| 167 | + # crates/jolt-cosmic/Cargo.toml gives: libcosmic drags iced, wgpu, | |
| 168 | + # cosmic-text and zbus in behind it, and none of that belongs in the | |
| 169 | + # dependency build a terminal backend waits on. | |
| 170 | + cosmicArtifacts = depsFor { | |
| 171 | + pname = "jolt-native-cosmic-deps"; | |
| 172 | + packages = [ "jolt-cosmic" ]; | |
| 173 | + }; | |
| 166 | 174 | |
| 167 | 175 | # The whole workspace, for the clippy and test runs — those do build |
| 168 | 176 | # everything, and want the sharing this split gives up. |
| @@ -179,7 +187,12 @@ | ||
| 179 | 187 | # crates/jolt-vidya. Nothing is silenced — a header that stops being |
| 180 | 188 | # there should fail the build rather than ship an object with no ABI |
| 181 | 189 | # beside it. |
| 182 | - soPackage = { pname, package, dir, soname, artifacts }: | |
| 190 | + # `headers` is false for a backend that exports no C API of its own. | |
| 191 | + # jolt-cosmic is one: the jolt side reaches it through jolt.ffi by | |
| 192 | + # symbol name, so there is no header for an embedder to include and no | |
| 193 | + # crates/jolt-cosmic/include to copy. The others keep the check that | |
| 194 | + # a vanished header fails the build. | |
| 195 | + soPackage = { pname, package, dir, soname, artifacts, headers ? true }: | |
| 183 | 196 | craneLib.buildPackage (commonArgs // { |
| 184 | 197 | inherit pname; |
| 185 | 198 | cargoArtifacts = artifacts; |
| @@ -187,8 +200,10 @@ | ||
| 187 | 200 | cargoExtraArgs = "--locked -p ${package}"; |
| 188 | 201 | doCheck = false; |
| 189 | 202 | installPhaseCommand = '' |
| 190 | - mkdir -p $out/lib $out/include | |
| 203 | + mkdir -p $out/lib | |
| 191 | 204 | cp target/release/${soname} $out/lib/ |
| 205 | + '' + lib.optionalString headers '' | |
| 206 | + mkdir -p $out/include | |
| 192 | 207 | cp -r crates/${dir}/include/. $out/include/ |
| 193 | 208 | ''; |
| 194 | 209 | }); |
| @@ -214,6 +229,14 @@ | ||
| 214 | 229 | dir = "jolt-moq"; |
| 215 | 230 | soname = "libjoltmoq.so"; |
| 216 | 231 | }; |
| 232 | + libjoltcosmic = soPackage { | |
| 233 | + artifacts = cosmicArtifacts; | |
| 234 | + pname = "libjoltcosmic"; | |
| 235 | + package = "jolt-cosmic"; | |
| 236 | + dir = "jolt-cosmic"; | |
| 237 | + soname = "libjoltcosmic.so"; | |
| 238 | + headers = false; | |
| 239 | + }; | |
| 217 | 240 | |
| 218 | 241 | # The phone. Same sources, same Cargo.lock, only the target |
| 219 | 242 | # configuration moves — which is what //:libs-android and its pair of |
| @@ -301,7 +324,7 @@ | ||
| 301 | 324 | packages = { |
| 302 | 325 | default = libs; |
| 303 | 326 | android = libsAndroid; |
| 304 | - inherit libs libvidya libjolttui libjoltmoq; | |
| 327 | + inherit libs libvidya libjolttui libjoltmoq libjoltcosmic; | |
| 305 | 328 | }; |
| 306 | 329 | |
| 307 | 330 | # Just the X11 client library on LD_LIBRARY_PATH, for `jolt gfx-demo`. |
| @@ -163,6 +163,14 @@ | |||
| 163 | pname = "jolt-native-moq-deps"; | 163 | pname = "jolt-native-moq-deps"; |
| 164 | packages = [ "jolt-moq" ]; | 164 | packages = [ "jolt-moq" ]; |
| 165 | }; | 165 | }; |
| 166 | + # Its own artifact rather than a share of the UI one, for the reason | ||
| 167 | + # crates/jolt-cosmic/Cargo.toml gives: libcosmic drags iced, wgpu, | ||
| 168 | + # cosmic-text and zbus in behind it, and none of that belongs in the | ||
| 169 | + # dependency build a terminal backend waits on. | ||
| 170 | + cosmicArtifacts = depsFor { | ||
| 171 | + pname = "jolt-native-cosmic-deps"; | ||
| 172 | + packages = [ "jolt-cosmic" ]; | ||
| 173 | + }; | ||
| 166 | 174 | ||
| 167 | # The whole workspace, for the clippy and test runs — those do build | 175 | # The whole workspace, for the clippy and test runs — those do build |
| 168 | # everything, and want the sharing this split gives up. | 176 | # everything, and want the sharing this split gives up. |
| @@ -179,7 +187,12 @@ | |||
| 179 | # crates/jolt-vidya. Nothing is silenced — a header that stops being | 187 | # crates/jolt-vidya. Nothing is silenced — a header that stops being |
| 180 | # there should fail the build rather than ship an object with no ABI | 188 | # there should fail the build rather than ship an object with no ABI |
| 181 | # beside it. | 189 | # beside it. |
| 182 | - soPackage = { pname, package, dir, soname, artifacts }: | 190 | + # `headers` is false for a backend that exports no C API of its own. |
| 191 | + # jolt-cosmic is one: the jolt side reaches it through jolt.ffi by | ||
| 192 | + # symbol name, so there is no header for an embedder to include and no | ||
| 193 | + # crates/jolt-cosmic/include to copy. The others keep the check that | ||
| 194 | + # a vanished header fails the build. | ||
| 195 | + soPackage = { pname, package, dir, soname, artifacts, headers ? true }: | ||
| 183 | craneLib.buildPackage (commonArgs // { | 196 | craneLib.buildPackage (commonArgs // { |
| 184 | inherit pname; | 197 | inherit pname; |
| 185 | cargoArtifacts = artifacts; | 198 | cargoArtifacts = artifacts; |
| @@ -187,8 +200,10 @@ | |||
| 187 | cargoExtraArgs = "--locked -p ${package}"; | 200 | cargoExtraArgs = "--locked -p ${package}"; |
| 188 | doCheck = false; | 201 | doCheck = false; |
| 189 | installPhaseCommand = '' | 202 | installPhaseCommand = '' |
| 190 | - mkdir -p $out/lib $out/include | 203 | + mkdir -p $out/lib |
| 191 | cp target/release/${soname} $out/lib/ | 204 | cp target/release/${soname} $out/lib/ |
| 205 | + '' + lib.optionalString headers '' | ||
| 206 | + mkdir -p $out/include | ||
| 192 | cp -r crates/${dir}/include/. $out/include/ | 207 | cp -r crates/${dir}/include/. $out/include/ |
| 193 | ''; | 208 | ''; |
| 194 | }); | 209 | }); |
| @@ -214,6 +229,14 @@ | |||
| 214 | dir = "jolt-moq"; | 229 | dir = "jolt-moq"; |
| 215 | soname = "libjoltmoq.so"; | 230 | soname = "libjoltmoq.so"; |
| 216 | }; | 231 | }; |
| 232 | + libjoltcosmic = soPackage { | ||
| 233 | + artifacts = cosmicArtifacts; | ||
| 234 | + pname = "libjoltcosmic"; | ||
| 235 | + package = "jolt-cosmic"; | ||
| 236 | + dir = "jolt-cosmic"; | ||
| 237 | + soname = "libjoltcosmic.so"; | ||
| 238 | + headers = false; | ||
| 239 | + }; | ||
| 217 | 240 | ||
| 218 | # The phone. Same sources, same Cargo.lock, only the target | 241 | # The phone. Same sources, same Cargo.lock, only the target |
| 219 | # configuration moves — which is what //:libs-android and its pair of | 242 | # configuration moves — which is what //:libs-android and its pair of |
| @@ -301,7 +324,7 @@ | |||
| 301 | packages = { | 324 | packages = { |
| 302 | default = libs; | 325 | default = libs; |
| 303 | android = libsAndroid; | 326 | android = libsAndroid; |
| 304 | - inherit libs libvidya libjolttui libjoltmoq; | 327 | + inherit libs libvidya libjolttui libjoltmoq libjoltcosmic; |
| 305 | }; | 328 | }; |
| 306 | 329 | ||
| 307 | # Just the X11 client library on LD_LIBRARY_PATH, for `jolt gfx-demo`. | 330 | # Just the X11 client library on LD_LIBRARY_PATH, for `jolt gfx-demo`. |