Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
789 lines (717 loc) · 33.4 KB
/
Copy pathflake.nix
File metadata and controls
789 lines (717 loc) · 33.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
{
description = "MoQ - Media over QUIC";
# nix.moq.dev caches the default branch's dev shell, along with moq-relay
# and moq on x86 Linux, with a 14-day expiry:
# nix run github:moq-dev/moq#moq-relay --accept-flake-config
# Release Nix retains tagged packages permanently once a release cut
# carries that workflow from main; earlier tags still build from source.
#
# --accept-flake-config opts into the nixConfig below for one command. To
# trust the cache permanently instead, add these settings to nix.conf.
#
# The CI paths expire 14 days after upload, possibly before a path
# that depends on them; `fallback` builds whatever is missing instead of
# failing the substitution.
nixConfig = {
extra-substituters = [ "https://nix.moq.dev" ];
extra-trusted-public-keys = [
"nix.moq.dev-1:BZ0DtCypDFv1ESX3hxuB42yc0vitSA1YHojSmVwB5bk="
];
fallback = true;
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# The quest CLI, which also serves the quest guide and skills the stubs in
# .claude/skills call. Bump the rev to upgrade them.
quest = {
url = "github:moq-dev/quest";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
quest,
...
}:
let
eachSupportedSystem = flake-utils.lib.eachSystem [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
in
{
nixosModules = {
moq-relay = import ./nix/modules/moq-relay.nix;
github-runner-vm = import ./nix/modules/github-runner-vm.nix;
};
overlays.default = import ./nix/overlay.nix;
}
// eachSupportedSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
# Pinned build toolchain (not latest stable) so `nix develop` and CI
# compile against a fixed rustc and the relay's MSRV can't creep up
# unnoticed. The floor is 1.98, not the 1.95 relay MSRV: earlier rustc
# strips Mach-O debuginfo with an llvm-objcopy that leaves the LINKEDIT
# string pool 4-byte aligned, which macOS 27's dyld refuses to load, so
# release-profile proc macros and cdylibs are a coin flip there. The
# crates still declare their own lower floors (Cargo.toml rust-version).
rust-toolchain = pkgs.rust-bin.stable."1.98.1".minimal.override {
# `minimal` rather than `default`, which adds 740 MB of offline HTML
# docs to a closure every CI job downloads.
extensions = [
"rustfmt"
"clippy"
"rust-src"
"rust-analyzer"
# llvm-cov and llvm-profdata for `just rs coverage`, which must
# match rustc's LLVM. cargo-llvm-cov finds them in the sysroot.
"llvm-tools"
];
targets = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
"aarch64-apple-darwin"
];
};
# GStreamer dependencies (for moq-gst plugin)
gstreamerDeps = with pkgs; [
gst_all_1.gstreamer
gst_all_1.gstreamer.dev
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
];
tsduck = pkgs.tsduck.overrideAttrs (
old:
pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
makeFlags = old.makeFlags ++ [ "CXXFLAGS_WARNINGS=" ];
}
);
# The CodSpeed Criterion build (`just rs codspeed`). 6.0 runs each benchmark in its own
# process, so allocator state no longer carries between them; nixpkgs still has 5.x.
cargo-codspeed = pkgs.cargo-codspeed.overrideAttrs (
finalAttrs: old: {
version = "6.0.0";
src = pkgs.fetchFromGitHub {
owner = "CodSpeedHQ";
repo = "codspeed-rust";
tag = "v${finalAttrs.version}";
hash = "sha256-qY+IQx2apIOGTkRXUnbNCJT4Jo6TESY/80SXyknUBWY=";
};
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
inherit (finalAttrs) pname version src;
hash = "sha256-qiyA74h80sT3tM/TToZxPDGMmnEwB8MYhFM84Wu2ySs=";
};
}
);
# Rust dependencies
rustDeps =
with pkgs;
[
rust-toolchain
just
git
cmake
pkg-config
# Sets LIBCLANG_PATH + BINDGEN_EXTRA_CLANG_ARGS so ffmpeg-sys-next's
# bindgen finds libc headers (<errno.h>) on hosts without system
# headers in /usr/include, e.g. the self-hosted runner.
rustPlatform.bindgenHook
glib
libressl
ffmpeg
# moq-video's `vpx` feature (VP8/VP9 software decode): libvpx-native-sys
# finds it through pkg-config, and `VPX_STATIC` below links the archive
# so nothing built here needs libvpx.so at runtime.
libvpx
curl
# MPEG-TS validation (tsp, tsanalyze) for the ts-compliance harness.
tsduck
cargo-sort
cargo-shear
cargo-edit
cargo-semver-checks
cargo-deny
cargo-bloat
# The workspace-hack that gives every build one feature set per dependency.
cargo-hakari
cargo-nextest
# Mutation testing of the route and resume code (`just rs mutants`).
cargo-mutants
cargo-codspeed
# Sets versions for a release cut; `sh/version.py` needs 0.4.1 or newer.
release-plz
# Source-based test coverage (`just rs coverage`).
# Its LLVM test helpers must read the compiler's profile format.
(cargo-llvm-cov.override {
rustPlatform = makeRustPlatform {
cargo = rust-toolchain;
# nixpkgs reads the LLVM its tests use from `rustc.llvmPackages`,
# which rust-overlay's toolchain lacks.
rustc = rust-toolchain // {
llvmPackages = llvmPackages_22;
};
};
})
]
++ gstreamerDeps
++ pkgs.lib.optionals (!pkgs.stdenv.hostPlatform.isDarwin) [
# cpal's `alsa-sys` (moq-audio `capture` / `playback` features) links
# libasound on Linux via pkg-config; macOS uses CoreAudio, so no dep
# there. See `alsaPlugins` below for reaching the default device at
# runtime.
pkgs.alsa-lib
# The `pulse` PCM, for a desktop whose default device routes through
# PulseAudio rather than the `pipewire` PCM below. Loaded at runtime
# only, via `alsaPlugins`.
pkgs.alsa-plugins
# A private clocked null device for native playback tests.
(pkgs.lib.getBin pkgs.pulseaudio)
# A shared session bus for the concurrent private audio server test.
pkgs.dbus
# moq-video's `pipewire` screen-capture feature: the pipewire crate
# links libpipewire-0.3 via pkg-config and generates bindings at build
# time (bindgenHook above provides libclang). Linux-only; macOS uses
# ScreenCaptureKit.
pkgs.pipewire
# Isolated X11 server for SHM/GetImage capture measurements.
pkgs.xvfb-run
];
# Where the shell's libasound looks for PCM plugins.
#
# ALSA's default device is a plugin on any desktop running a sound
# server: `pipewire` (shipped by pipewire itself) or `pulse` (from
# alsa-plugins). The shell's alsa-lib only searches its own store path,
# which holds neither, so opening the default device fails with ENXIO
# and audio only works against raw `hw:` devices. The host's plugins are
# not a substitute: they link the host's libasound and libpipewire, so
# loading them into a Nix-built binary hits a glibc version mismatch.
#
# ALSA_PLUGIN_DIR takes one directory, hence the join.
alsaPlugins = pkgs.symlinkJoin {
name = "moq-alsa-plugins";
paths = [
pkgs.alsa-plugins
pkgs.pipewire
];
};
# JavaScript dependencies
jsDeps = with pkgs; [
bun
# Only for NPM publishing
nodejs_24
# One browser build for local and CI Playwright checks.
playwright-driver.browsers
];
# Python dependencies
pyDeps = with pkgs; [
uv
python3
];
# CDN/deployment dependencies
cdnDeps = with pkgs; [
opentofu
];
# IETF Internet-Draft tooling (drafts/justfile). kramdown-rfc renders
# the kramdown-rfc markdown to RFC XML; xml2rfc produces the txt/html;
# mmark covers any mmark-format drafts; libxml2 provides xmllint.
draftsDeps = with pkgs; [
rubyPackages.kramdown-rfc2629
xml2rfc
mmark
libxml2
];
# Tools for producing .deb/.rpm artifacts. Cross-platform so that
# `just rs package` works from `nix develop` on both Linux and macOS.
packagingDeps = with pkgs; [
nfpm
rpm
dpkg
gettext
# cargo-zigbuild + zig let CI build a single binary that links
# against an older glibc (passed as `<triple>.<glibc>`), so the
# same artifact ships in both .deb and .rpm. No docker needed.
cargo-zigbuild
zig
];
# Tools needed to regenerate and sign the apt/rpm repositories.
# Linux-only because apt and createrepo_c are marked broken on Darwin
# in nixpkgs. The publish workflows only ever run on Linux runners.
publishDeps =
with pkgs;
lib.optionals (!stdenv.hostPlatform.isDarwin) [
apt
createrepo_c
rclone
gnupg
gzip
];
# Developer workflow tooling not needed for builds: jq reads
# `cargo metadata` in `just rs check-changed`.
devTools = with pkgs; [
jq
# Runs the moq.sh installer tests under a strict POSIX shell.
dash
# Proves the temporary bench relay owns its TCP and UDP sockets.
lsof
];
# Linters / formatters used by `just check` and `just fix`, which
# skip a module whose tools aren't on $PATH. CI sets CI_STRICT=1,
# which turns that skip into an error (see the tools map in
# sh/dispatch.sh), so this list and that one have to stay in step.
lintDeps =
with pkgs;
[
shellcheck
shfmt
actionlint
zizmor
taplo
nixfmt
# Formats and lints every Python file; the same version uv.lock pins.
ruff
]
# Apple's formatter, so `just swift check` checks formatting off macOS
# too. nixpkgs marks the Swift compiler it builds with broken on
# aarch64-linux, where the check skips instead.
++ lib.optionals (!(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64)) [
swift-format
];
# Kotlin wrapper (kt/) toolchain so `just kt check` actually compiles
# the wrapper and runs :moq:jvmTest instead of silently skipping.
# Pinned to gradle 8.x (Kotlin 2.0.21's Gradle plugin predates Gradle
# 9) and JDK 17 (the wrapper's jvmTarget). Cross-platform: the kt check
# builds moq-ffi for the host and runs on both Linux and macOS.
ktDeps = with pkgs; [
jdk17
gradle_8
# `just kt check` fails on Kotlin it would reformat; `just kt fix` applies it.
ktfmt
];
# uniffi-bindgen-go renders rs/moq-ffi into the generated half of
# go/ffi. Not in nixpkgs, so build it from source; without it `just go
# check` skips itself, which reads as a pass in CI.
#
# The tag pairs the generator's own version with the uniffi release it
# targets (v0.10.0-kixelated.3+v0.32.0 -> uniffi 0.32), and it only
# understands metadata emitted by that uniffi, so it moves with the `uniffi`
# dependency in rs/moq-ffi/Cargo.toml. Five other places name the same
# generator version and must be bumped together: the commit the tag
# peels to in .github/actions/uniffi-bindgen, which CI jobs outside
# the dev shell build, and the `cargo install` line in
# rs/moq-ffi/build.sh, go/ffi/README.md, sh/go/check.sh, and
# sh/go/stage.sh.
#
# This points at a fork rather than NordSecurity because upstream has no
# uniffi 0.32 generator: the metadata encoding changed in 0.32 even
# though the contract version did not, so v0.7.1+v0.31.0 fails to read a
# 0.32-built cdylib at all. The fork carries the port, tracked upstream
# as NordSecurity/uniffi-bindgen-go#96, renders an enum error's
# exported Display as its Error(), destroys an async result whose
# context was cancelled as it completed, and renders each call binding's
# FFI call once, which cuts its own build from about 15 GB of memory to
# under 2 GB. Move back to NordSecurity once they tag a 0.32 release
# carrying all four.
uniffi-bindgen-go = pkgs.rustPlatform.buildRustPackage rec {
pname = "uniffi-bindgen-go";
version = "0.10.0-kixelated.3+v0.32.0";
src = pkgs.fetchFromGitHub {
owner = "kixelated";
repo = "uniffi-bindgen-go";
rev = "v${version}";
hash = "sha256-+vg+jvYzsdUjOz5qVsfoDmj78fE5zPajvpPREERATDQ=";
};
cargoHash = "sha256-VWLi97JMQjBo3RCJI2rbdTqK4956dcvsiLGq1xVNcl4=";
# The tag is a virtual workspace whose other members are uniffi test
# fixtures. Building from the root would compile all of them, and CI
# has no Nix binary cache, so it would pay for that on every run.
buildAndTestSubdir = "bindgen";
# The upstream test suite generates fixtures and compiles them with a
# Go toolchain, which is a lot of build for a binary we only invoke.
doCheck = false;
};
# Go toolchain (go/) so `just go check` regenerates the bindings and
# runs `go test -race` on the wrapper instead of skipping. Cross-platform:
# the check builds moq-ffi for the host and runs on Linux and macOS.
goDeps = [
pkgs.go
uniffi-bindgen-go
# `just go audit`, nightly.
pkgs.govulncheck
];
# uniffi-bindgen-dart renders rs/moq-ffi into dart/moq_ffi. The fork
# carries the uniffi 0.32 port, library-mode CLI, and RustBuffer leak
# fixes while those changes remain open upstream. Its tags add a
# `-kixelated.N` pre-release so they never collide with upstream's.
uniffi-bindgen-dart = pkgs.rustPlatform.buildRustPackage rec {
pname = "uniffi-bindgen-dart";
version = "0.3.1-kixelated.7+v0.32.0";
src = pkgs.fetchFromGitHub {
owner = "kixelated";
repo = "uniffi-dart";
rev = "v${version}";
hash = "sha256-uSApyCocEhADWu8Koj5vXIt0fMYQVjnBVKctDWQHqLM=";
};
# The upstream repository ignores Cargo.lock so cargo installs test
# the unlocked resolver. Nix still consumes committed lock data.
cargoLock.lockFile = ./nix/uniffi-dart-Cargo.lock;
# Carry record converter, per-operation cancellation, and negative duration fixes at the source.
patches = [
./nix/uniffi-dart-record-error.patch
./nix/uniffi-dart-cancellation.patch
./nix/uniffi-dart-duration-negative.patch
];
postPatch = ''
cp ${./nix/uniffi-dart-Cargo.lock} Cargo.lock
'';
buildFeatures = [ "binary" ];
cargoBuildFlags = [ "--bin=uniffi_bindgen_dart" ];
doCheck = false;
};
# uniffi-bindgen-cpp renders rs/moq-ffi for the CMake builds of cpp/moq and,
# with its C backend, c/moq. Not in nixpkgs, so build it from source;
# without it `just check` skips the c and cpp modules, which CI_STRICT
# turns into a failure in CI.
#
# Like uniffi-bindgen-go, the tag pairs the generator's version with the
# uniffi release it reads, so it moves with the `uniffi` dependency in
# rs/moq-ffi/Cargo.toml. The other places name the same tag and must be
# bumped together: the commit the tag peels to in
# .github/actions/uniffi-bindgen, which CI jobs outside the dev shell
# (Windows among them) build, and the `cargo install` lines in
# rs/moq-ffi/build.sh and cpp/moq/README.md.
#
# This points at a fork of LiveKit's async branch (livekit/uniffi-bindgen-cpp
# PR #1): neither LiveKit nor NordSecurity has a uniffi 0.32 generator,
# and the fork adds `error_style = "expected"`, `strip_type_prefix`, and
# `strip_function_prefix`, which cpp/moq/uniffi.toml turns on, and C
# functions for an object's exported traits (`moq_instance_eq`). Its tags
# add a `-kixelated.N` pre-release so they never collide with upstream's.
# Move back upstream once one tags both.
uniffi-bindgen-cpp = pkgs.rustPlatform.buildRustPackage rec {
pname = "uniffi-bindgen-cpp";
version = "0.11.0-kixelated.8+v0.32.2";
src = pkgs.fetchFromGitHub {
owner = "kixelated";
repo = "uniffi-bindgen-cpp";
rev = "v${version}";
hash = "sha256-ziqwP54PsSOmOzZXax6WZDtrnEtwzyMhTHD1g7aPraM=";
};
cargoHash = "sha256-jWMxmzxU815OhdDnoVfIdOkOC+HijX/gs6BOdDIDTyY=";
# The workspace's other member is the fixture crate, which pulls the
# uniffi examples in from git; build only the generator.
buildAndTestSubdir = "bindgen";
# The upstream tests generate fixtures and compile them with CMake,
# which is a lot of build for a binary we only invoke.
doCheck = false;
};
# C++ binding generator; CMake comes from rustDeps and the compiler from stdenv.
cppDeps = [
uniffi-bindgen-cpp
];
# Dart bindings plus the pinned external generator.
dartDeps = [
pkgs.dart
uniffi-bindgen-dart
];
# The libobs headers, unpacked from the same OBS release
# cpp/obs/buildspec.json downloads. Headers only: nothing here links, so
# it works on Darwin even though obs-studio itself does not build there,
# and it costs ~2 MB of store instead of the multi-hundred-MB obs-deps
# bundle. `just obs compile` type-checks the plugin against it.
#
# Keep `version` equal to buildspec.json's obs-studio version; `just obs
# check` fails when the two drift, and when either drifts a minor
# release from the nixpkgs obs-studio below.
obs-headers = pkgs.stdenvNoCC.mkDerivation rec {
pname = "libobs-headers";
version = "32.2.2";
src = pkgs.fetchzip {
url = "https://github.com/obsproject/obs-studio/archive/refs/tags/${version}.tar.gz";
hash = "sha256-miLe4MhiVhLlPvwzDjL31BwdcjVhgWvmcSzH9pgZV6U=";
};
dontBuild = true;
# The layout matches a real OBS install (everything flat under
# include/obs, frontend API included), so a plugin's include paths are
# the same here as against the system package on Linux.
installPhase = ''
runHook preInstall
(cd libobs && find . \( -name '*.h' -o -name '*.hpp' \) -exec install -Dm444 {} $out/include/obs/{} \;)
install -Dm444 frontend/api/obs-frontend-api.h $out/include/obs/obs-frontend-api.h
# obs.h includes obsconfig.h, which the OBS build generates. Only the
# two version macros have to hold a value; everything else it
# configures is internal to libobs, so leave the #cmakedefines unset.
sed -e 's/^#cmakedefine.*$//' -e 's/@OBS_RELEASE_CANDIDATE@/0/' -e 's/@OBS_BETA@/0/' \
libobs/obsconfig.h.in > $out/include/obs/obsconfig.h
runHook postInstall
'';
};
# Dependencies for the OBS plugin (`just obs build`, `just obs compile`,
# `just obs check`). ffmpeg + cmake come from rustDeps.
#
# Only the *build* is Linux-only: nixpkgs' obs-studio lists no Darwin
# platform, so macOS and Windows link libobs/Qt6 from the OBS buildspec
# bundle instead (see cpp/obs/buildspec.json and doc/bin/obs.md).
# Type-checking needs headers rather than libraries, and those are
# cross-platform -- obs-headers above, plus qt6.qtbase, which does build
# on Darwin. So `just obs compile` and the lints run everywhere while
# `just obs build` stays native. On Linux it links nixpkgs' obs-studio,
# which only the `.#obs` shell below carries.
obsDeps =
with pkgs;
[
obs-headers
# libobs' public headers include <simde/x86/sse2.h> as of OBS 32,
# which used to be vendored under libobs/util/ and so travelled with
# obs-headers. obs-deps ships it beside libobs for the macOS and
# Windows builds, and nixpkgs' obs-studio propagates it for the
# Linux one; listed here so the header-only path has it on Darwin
# too. Same 0.8.2 that obs-deps carries.
simde
qt6.qtbase
# clang-format, for the plugin and the c/ and cpp/moq packages.
clang-tools
gersemi
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
ninja
];
# The obs-studio `just obs ci` links against on Linux, which is a third
# version alongside buildspec.json and obs-headers and the only one this
# repo doesn't choose. Read the string on every platform, Darwin
# included, so `just obs check` compares it everywhere rather than only
# where the package builds. It moves when flake.lock does, so the guard
# fails on the nixpkgs bump that opens the gap.
obs-linked-version = pkgs.obs-studio.version;
# Apply our overlay to get the package definitions
overlayPkgs = pkgs.extend self.overlays.default;
quest-cli = quest.packages.${system}.default;
in
{
packages = (rec {
default = pkgs.symlinkJoin {
name = "moq-all";
paths = [
moq-relay
moq
];
};
# Named after the executable. The overlay keeps `moq-cli` because
# nixpkgs already has an unrelated `moq`.
moq = overlayPkgs.moq-cli;
# The package was `moq-cli` through 0.12.2. Refuse with the new name
# so `nix run` and `nix profile upgrade` break instead of going stale.
moq-cli = pkgs.writeShellScriptBin "moq" ''
echo "error: the moq-cli package is now moq: nix run github:moq-dev/moq/release#moq" >&2
exit 1
'';
# Inherit packages from the overlay
inherit (overlayPkgs)
moq-relay
moq-bench
moq-boy
libmoq
moq-gst
;
inherit uniffi-bindgen-cpp uniffi-bindgen-dart;
# The @moq/libav npm package, which js/libav/build.ts copies into js/libav/dist.
moq-libav = pkgs.callPackage ./js/libav/package.nix { };
# The quest CLI alone, so quest.yml can validate the tree without
# realising the whole dev shell.
quest = quest-cli;
# Bundle of packaging + repo-publish tooling, pinned via flake.lock.
# CI builds this and prepends its bin/ to $PATH so subsequent steps
# use the same versions a local `nix develop` user would.
packaging = pkgs.symlinkJoin {
name = "moq-packaging-tools";
paths = packagingDeps ++ publishDeps;
};
});
# Re-export gst_all_1 so users can pair the plugin with a matching
# gstreamer in one nix invocation:
# nix shell .#moq-gst .#gst_all_1.gstreamer --command gst-inspect-1.0 moq
# Sourcing from the same nixpkgs the moq-gst build linked against
# avoids the duplicate-symbol crash you get with
# `nixpkgs#gst_all_1.gstreamer`, which can resolve to a different
# store hash. Lives under legacyPackages because nested attrsets
# are disallowed in the flake `packages` schema.
legacyPackages = {
inherit (pkgs) gst_all_1;
# Nightly conformance needs both pinned Moxygen endpoints. Keep this
# C++ dependency build out of the default shell and flake checks.
moxygen = pkgs.callPackage ./nix/moxygen.nix { };
runner-userns-profile = import ./nix/runner/unshare.nix { inherit pkgs; };
# Nightly `just test route-proof` type-checks the route rule's convergence
# proof. Its own Agda pin, so neither the dev shell nor `nix flake check`
# fetches it.
route-proof = import ./nix/route-proof.nix { inherit system; };
# The QUIC Interop Runner's host tools (`just test quic-interop`): tshark
# reads its pcaps, OpenSSL makes its certificates (the dev shell's LibreSSL
# has no config for them), and Compose drives Podman where Docker's plugin is
# absent. Kept out of the dev shell, which every CI job downloads.
quic-interop = pkgs.buildEnv {
name = "quic-interop-tools";
paths = [
pkgs.docker-compose
pkgs.openssl
pkgs.wireshark-cli
];
};
# The gate's `just rs send-depth` proves moq-net's Send futures on it.
# Pinned so a toolchain release alone never fails that check;
# bump it on purpose, like the stable toolchain above. Kept out of
# the dev shell, which every CI job downloads.
rust-nightly = pkgs.rust-bin.nightly."2026-10-18".minimal;
# `nix develop .#obs`: the default shell plus obs-studio, which linking
# the plugin on Linux needs (`just obs build`, `just obs ci`). Kept out
# of the default shell because it pulls in ~3 GB (CEF, mostly) that
# every other CI job would download. Under legacyPackages rather than
# devShells so `nix flake check` doesn't build it on every Rust PR.
obs = self.devShells.${system}.default.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.obs-studio ];
});
};
devShells.default = pkgs.mkShell {
packages =
rustDeps
++ jsDeps
++ pyDeps
++ cdnDeps
++ draftsDeps
++ packagingDeps
++ lintDeps
++ obsDeps
++ ktDeps
++ goDeps
++ cppDeps
++ dartDeps
++ devTools
++ [ quest-cli ]
# `just bench-profile`: perf records relay waits and CPU stacks, and
# jemalloc's jeprof symbolizes heap snapshots.
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
pkgs.perf
pkgs.jemalloc
];
# jemalloc's configure uses -O0 test builds, which conflict with
# Nix's _FORTIFY_SOURCE hardening (requires -O).
hardeningDisable = [ "fortify" ];
# The pinned Rust toolchain goes on PATH ahead of everything the
# host had, which shadows the Cargo shim `mbx setup` installs. Put it
# back in front, so a bare `cargo` in this shell reaches the same
# wrapper it reaches outside. `setup --status` is what knows where
# that shim lives, naming it on its first line even when it is
# missing. Its exit code is no guide: it also fails over unrelated
# setup, such as a rust-analyzer config `mbx setup` never wrote, so
# only the shim existing decides.
#
# CI included: `.github/actions/rust-cache` runs `mbx setup` so this
# finds a shim there too. That is the only way mbx reaches a build
# that spawns Cargo itself, which release-plz does.
shellHook = ''
# `nix develop` points TMPDIR at a fresh nix-shell.* dir that it
# never removes. Drop it and keep the caller's TMPDIR, as nix-direnv
# does, so nothing piles up there.
if [[ ''${NIX_BUILD_TOP-} == */nix-shell.* && -d $NIX_BUILD_TOP ]]; then
rm -rf "$NIX_BUILD_TOP"
export TMPDIR=''${NIX_BUILD_TOP%/*}
unset NIX_BUILD_TOP TMP TEMP TEMPDIR
fi
status=$(mbx setup --status 2>/dev/null || true)
shim=$(printf '%s\n' "$status" | sed -n '1s/.*: //p')
if [ -x "$shim" ]; then
export PATH="$(dirname "$shim"):$PATH"
fi
# Skills also invoke quest directly, so keep it ahead of host installs.
export PATH="${quest-cli}/bin:$PATH"
# Each nested shell (direnv, then `nix develop`, then another
# inside a gate) prepends this shell's ~160 store paths again,
# about 10 KB. mbx copies PATH into two variables at ~3.6 times
# its size, and Linux rejects any one variable over 128 KiB, so
# four nested shells failed every Cargo launch with E2BIG. Keep
# each directory's first entry only: lookups resolve as before.
PATH=$(printf '%s' "$PATH" | awk -v RS=: '!seen[$0]++ { printf "%s%s", sep, $0; sep = ":" }')
'';
# moq binaries reject any MOQ_* variable they don't read, so the
# shell must export none.
env =
let
vars = {
# What sh/dispatch.sh checks before a scoped `just check` or `just
# fix`. IN_NIX_SHELL would also pass inside another project's shell.
IN_MOQ_DEV_SHELL = "1";
# Local launchers need the exact build without evaluating the flake again.
# QUEST_* belongs to quest itself.
DEV_SHELL_QUEST = "${quest-cli}/bin/quest";
PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}";
PLAYWRIGHT_VERSION = pkgs.playwright-driver.version;
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = "true";
# Where `just obs compile` and `just obs test` look for libobs. Set
# on every platform so the plugin type-checks against the pinned OBS
# release everywhere, rather than whatever the host happens to have.
OBS_INCLUDE_DIR = "${obs-headers}/include/obs";
# What `just obs check` compares the two in-repo OBS pins against.
# Exported rather than read back out of nix, so the guard costs a
# variable lookup instead of a nested evaluation of this flake.
OBS_LINKED_VERSION = obs-linked-version;
# Link libvpx statically for moq-video's `vpx` feature, the shape the
# quest ships: no system codec library at runtime.
VPX_STATIC = "1";
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.hostPlatform.isDarwin) {
ALSA_PLUGIN_DIR = "${alsaPlugins}/lib/alsa-lib";
# Firefox loads these at runtime; harness.ts exposes them only to its process.
PLAYWRIGHT_FIREFOX_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.ffmpeg
pkgs.libpulseaudio
];
};
moq = builtins.filter (pkgs.lib.hasPrefix "MOQ_") (builtins.attrNames vars);
in
assert pkgs.lib.assertMsg (
moq == [ ]
) "dev shell must not export MOQ_* (moq binaries reject them): ${toString moq}";
vars;
};
formatter = pkgs.nixfmt-tree;
# Heavy Rust CI (clippy / doc / test) runs via `just check` and `just
# test` (see rs/justfile), reaching mbx through the Cargo shim the dev
# shell puts on PATH. `nix flake check` validates flake eval and builds
# the checks below; the dispatcher runs it for Nix and packaging
# inputs. Release artifacts build per crate (nix/crates.nix).
#
# Which compiler cache those runs get is a workflow concern
# (`.github/actions/rust-cache`); nothing here configures it.
checks = {
# The per-crate source filter keeps what moq-video embeds.
package-source-assets =
let
moq-video = pkgs.lib.findFirst (
crate: crate.crateName == "moq-video"
) (throw "moq-boy links no moq-video") overlayPkgs.moq-boy.completeDeps;
in
pkgs.runCommand "package-source-assets" { } ''
test -f "${moq-video.src}/src/frame/nv12_resize.ptx"
touch "$out"
'';
}
// pkgs.lib.optionalAttrs (system == "x86_64-linux") (
import ./nix/runner/checks.nix { inherit pkgs; }
);
}
);
}