-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathflake.nix
More file actions
320 lines (292 loc) · 10.6 KB
/
Copy pathflake.nix
File metadata and controls
320 lines (292 loc) · 10.6 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
{
description = "MoQ - Media over QUIC";
# Pre-built binaries live in our Cachix cache. Only tagged releases are
# pushed (CI fires on moq-relay-v*, moq-cli-v*, etc.), so pin the flake ref
# to a recent tag to get a hit. The default branch HEAD is not cached and
# builds from source:
# nix run github:moq-dev/moq/moq-relay-v0.12.4#moq-relay --accept-flake-config
#
# --accept-flake-config opts into the nixConfig below for one command. To
# trust the cache permanently instead, run: cachix use kixelated
nixConfig = {
extra-substituters = [ "https://kixelated.cachix.org" ];
extra-trusted-public-keys = [
"kixelated.cachix.org-1:CmFcV0lyM6KuVM2m9mih0q4SrAa0XyCsiM7GHrz3KKk="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
crane,
rust-overlay,
...
}:
{
nixosModules = {
moq-relay = import ./nix/modules/moq-relay.nix;
};
overlays.default = import ./nix/overlay.nix { inherit crane; };
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rust-toolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer"
];
targets = [
"wasm32-unknown-unknown"
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
"x86_64-apple-darwin"
"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.isDarwin {
makeFlags = old.makeFlags ++ [ "CXXFLAGS_WARNINGS=" ];
}
);
# 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
curl
# MPEG-TS validation (tsp, tsanalyze) for the ts-compliance harness.
tsduck
cargo-sort
cargo-shear
cargo-edit
cargo-semver-checks
cargo-deny
cargo-nextest
# Browser/WASM bindings (rs/moq-wasm -> @moq/wasm via `just wasm`).
# wasm-bindgen-cli must match the `wasm-bindgen` crate version (the
# crate is pinned to nixpkgs' CLI version); bump both together.
wasm-bindgen-cli
]
++ gstreamerDeps
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
# Marked broken on Darwin in nixpkgs, but builds fine on Linux.
pkgs.release-plz
# cpal's `alsa-sys` (moq-audio `capture` feature) links libasound on
# Linux via pkg-config; macOS uses CoreAudio, so no dep there.
pkgs.alsa-lib
];
# JavaScript dependencies
jsDeps = with pkgs; [
bun
# Only for NPM publishing
nodejs_24
# JSR publishing. We call `deno publish` directly instead of `bunx jsr`
# so the release doesn't race on a runtime binary download.
deno
];
# 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
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.isDarwin) [
apt
createrepo_c
rpm
rclone
gnupg
gzip
];
# Developer workflow tooling not needed for builds: the GitHub CLI
# for opening/reviewing PRs from the dev shell.
devTools = with pkgs; [
gh
];
# Linters / formatters required by `just ci`; `just check` and
# `just fix` guard each tool with `command -v` so they skip
# silently when the binary isn't on $PATH.
lintDeps = with pkgs; [
shellcheck
shfmt
actionlint
taplo
nixfmt
];
# 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
];
# Dependencies for building the OBS plugin (`just obs build`).
# Linux-only: nixpkgs marks obs-studio broken on Darwin, so macOS
# and Windows fetch libobs/Qt6 via the OBS buildspec instead (see
# cpp/obs/buildspec.json and doc/bin/obs.md). ffmpeg + cmake come from
# rustDeps. clang-tools/gersemi back `just obs check`.
obsDeps =
with pkgs;
lib.optionals (!stdenv.isDarwin) [
obs-studio
qt6.qtbase
ninja
clang-tools
gersemi
];
# Apply our overlay to get the package definitions
overlayPkgs = pkgs.extend self.overlays.default;
in
{
packages = (rec {
default = pkgs.symlinkJoin {
name = "moq-all";
paths = [
moq-relay
moq-cli
moq-token
];
};
# Inherit packages from the overlay
inherit (overlayPkgs)
moq-relay
moq-cli
moq-bench
moq-token
moq-token-cli
moq-boy
libmoq
moq-gst
;
# 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;
};
})
# x86_64-darwin release artifacts are cross-compiled from the
# aarch64-darwin runner (see nix/overlay.nix). The cross outputs only
# evaluate on an aarch64-darwin host, so gate them on the system to
# keep `nix flake check` working on Linux and Intel macs.
// pkgs.lib.optionalAttrs (system == "aarch64-darwin") {
inherit (overlayPkgs)
moq-relay-x86_64-apple-darwin
moq-cli-x86_64-apple-darwin
moq-bench-x86_64-apple-darwin
moq-token-x86_64-apple-darwin
moq-token-cli-x86_64-apple-darwin
libmoq-x86_64-apple-darwin
moq-gst-plugin-x86_64-apple-darwin
;
};
# 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;
};
devShells.default = pkgs.mkShell {
packages =
rustDeps
++ jsDeps
++ pyDeps
++ cdnDeps
++ draftsDeps
++ packagingDeps
++ lintDeps
++ obsDeps
++ ktDeps
++ devTools;
# jemalloc's configure uses -O0 test builds, which conflict with
# Nix's _FORTIFY_SOURCE hardening (requires -O).
hardeningDisable = [ "fortify" ];
};
formatter = pkgs.nixfmt-tree;
# Heavy Rust CI (clippy / doc / test) runs as plain cargo via `just rs
# ci` (see rs/justfile), no longer through crane. `nix flake check` is
# kept -- it still validates flake eval + builds the dev shell -- but no
# longer compiles the workspace, so it's cheap. Release artifacts still
# build via crane `buildPackage` (see `packages` above / release-*.yml).
#
# On the self-hosted runner those cargo checks transparently reuse a
# persistent CARGO_TARGET_DIR (set in the runner environment), so a
# Cargo.lock change recompiles only the changed crate + its reverse-deps
# and unchanged crates are reused across jobs. That's a runner-side
# concern -- nothing here or in the workflows configures it.
checks = { };
}
);
}