This repository has no description
2.4 kB
59 lines
1{ self, ... }:
2{
3 perSystem =
4 { pkgs, system, ... }:
5 let
6 # Client omp carrying covibe's env-driven headless collab autostart
7 # (OMP_COLLAB_*) -- the exact patch the neoprism covibe service uses. A
8 # session started from any machine hosts natively against the covibe
9 # relay and is immediately joinable / browser-viewable. It does NOT show
10 # up in the covibe dashboard overview: that list is built from a local
11 # spool dir + local pid liveness + a per-session unix socket, so it only
12 # enumerates sessions running on the dashboard host.
13 ompCollab = self.legacyPackages.${system}.llm.omp.overrideAttrs (o: {
14 patches = (o.patches or [ ]) ++ [ ../../2configs/omp-collab-autostart.patch ];
15 });
16 in
17 {
18 packages.covibe =
19 (pkgs.writeShellApplication {
20 name = "covibe";
21 runtimeInputs = [
22 pkgs.coreutils
23 pkgs.qrencode
24 ];
25 text = ''
26 relay="''${COVIBE_RELAY:-wss://covibe.lassul.us}"
27 web="''${COVIBE_WEB:-https://covibe.lassul.us/c}"
28 host="''${COVIBE_RELAY_HOST:-covibe.lassul.us}"
29
30 # Mint an omp-compatible collab room, matching covibe's collablink:
31 # room = base64url(16 random bytes) -> 22 chars
32 # secret = base64url(32-byte AES key + 16-byte token) -> 64 chars
33 # Handing these to omp via OMP_COLLAB_ROOM/KEY makes the shareable
34 # link stable and known up front (no scraping the TUI).
35 room="$(head -c 16 /dev/urandom | basenc --base64url -w0 | tr -d '=')"
36 secret="$(head -c 48 /dev/urandom | basenc --base64url -w0 | tr -d '=')"
37
38 join="''${host}/r/''${room}.''${secret}"
39 browser="''${web}/#''${join}"
40
41 export OMP_COLLAB_RELAY="$relay"
42 export OMP_COLLAB_WEB="$web"
43 export OMP_COLLAB_ROOM="$room"
44 export OMP_COLLAB_KEY="$secret"
45
46 {
47 printf '\n covibe: hosting this session on %s\n\n' "$host"
48 printf ' omp join %s\n' "$join"
49 printf ' browser %s\n\n' "$browser"
50 qrencode -t UTF8 -m 2 "$browser" || true
51 printf '\n'
52 } >&2
53
54 exec ${ompCollab}/bin/omp "$@"
55 '';
56 }).overrideAttrs
57 { passthru.usage = builtins.readFile ./usage.kdl; };
58 };
59}