2023-08-30 01:50:06 +00:00
# usage:
# - start a DM with a rando via
# - '+' -> 'start conversation'
# - add a user to your roster via
# - '+' -> 'start conversation' -> '+' (opens the "add contact" dialog)
# - this triggers a popup on the remote side asking them for confirmation
# - after the remote's confirmation there will be a local popup for you to allow them to add you to their roster
# - to make a call:
# - ensure the other party is in your roster
# - open a DM with the party
# - click the phone icon at top (only visible if other party is in your roster)
2023-09-21 19:40:12 +00:00
#
# dino can be autostarted on login -- useful to ensure that i always receive calls and notifications --
# but at present it has no "start in tray" type of option: it must render a window.
2023-10-07 00:58:11 +00:00
#
# outstanding bugs:
2024-04-02 04:57:11 +00:00
# - NAT holepunching burns CPU/NET when multiple interfaces are up
# - fix by just `ip link set ovpnd-xyz down`
# - setting `wg-home` down *seems* to be not necessary
# - characterized by UPnP/SOAP error 500/718 in wireshark
# - seems it asks router A to open a port mapping for an IP address which belongs to a different subnet...
2023-10-07 00:58:11 +00:00
# - mic is sometimes disabled at call start despite presenting as enabled
# - fix is to toggle it off -> on in the Dino UI
2023-10-07 08:27:35 +00:00
# - default mic gain is WAY TOO MUCH (heavily distorted)
# - TODO: dino should have more optimal niceness/priority to ensure it can process its buffers
2023-10-11 05:40:19 +00:00
# - possibly this is solved by enabling RealtimeKit (rtkit)
# - TODO: see if Dino calls work better with `echo full > /sys/kernel/debug/sched/preempt`
2023-10-07 08:27:35 +00:00
#
# probably fixed:
2023-10-07 00:58:11 +00:00
# - once per 1-2 minutes dino will temporarily drop mic input:
# - `rtp-WRNING: plugin.vala:148: Warning in pipeline: Can't record audio fast enough
# - this was *partially* fixed by bumping the pipewire mic buffer to 2048 samples (from ~512)
2023-10-07 08:27:35 +00:00
# - this was further fixed by setting PULSE_LATENCY_MSEC=20.
# - possibly Dino should be updated internally: `info.rate / 100` -> `info.rate / 50`.
# - i think that affects the batching for echo cancellation, adaptive gain control, etc.
2023-10-07 01:30:45 +00:00
#
2024-04-02 04:57:11 +00:00
{ config , lib , pkgs , . . . }:
2023-09-21 19:40:12 +00:00
let
cfg = config . sane . programs . dino ;
in
2023-08-28 08:48:35 +00:00
{
2023-09-21 19:40:12 +00:00
sane . programs . dino = {
configOption = with lib ; mkOption {
default = { } ;
type = types . submodule {
options . autostart = mkOption {
type = types . bool ;
2023-12-14 01:57:32 +00:00
default = true ;
2023-09-21 19:40:12 +00:00
} ;
} ;
} ;
2024-04-02 04:57:11 +00:00
packageUnwrapped = pkgs . dino . overrideAttrs ( upstream : {
# i'm updating experimentally to see if it improves call performance.
# i don't *think* this is actually necessary; i don't notice any difference.
version = " 0 . 4 . 3 - u n s t a b l e - 2 0 2 4 - 0 4 - 0 1 " ;
src = lib . warnIf ( lib . versionOlder " 0 . 4 . 3 " upstream . version ) " d i n o u p d a t e : s a f e t o r e m o v e s a n e p a t c h e s " pkgs . fetchFromGitHub {
owner = " d i n o " ;
repo = " d i n o " ;
rev = " d 9 f a 4 d a a 6 a 7 d 1 6 f 5 f 0 e 2 1 8 3 a 7 7 e e 2 d 0 7 8 4 9 d d 9 f 3 " ;
hash = " s h a 2 5 6 - v J B I M s M L l K 8 A w 1 9 f D 2 a F N t e g X k j O q E g b 3 m 1 h i 3 f E 5 D E = " ;
} ;
checkPhase = ''
runHook preCheck
./xmpp-vala-test
# ./signal-protocol-vala-test # doesn't exist anymore
runHook postCheck
'' ;
} ) ;
2024-01-23 14:12:52 +00:00
sandbox . method = " b w r a p " ;
2024-02-08 21:51:32 +00:00
sandbox . net = " c l e a r n e t " ;
2024-02-13 11:14:38 +00:00
sandbox . whitelistAudio = true ;
2024-02-13 11:58:12 +00:00
sandbox . whitelistDbus = [ " u s e r " ] ; # notifications
2024-02-13 11:14:38 +00:00
sandbox . whitelistDri = true ; #< not strictly necessary, but we need all the perf we can get on moby
2024-02-14 01:49:49 +00:00
sandbox . whitelistWayland = true ;
2024-02-15 00:49:24 +00:00
sandbox . extraHomePaths = [
" M u s i c "
2024-02-27 21:36:18 +00:00
" P i c t u r e s / a l b u m s "
" P i c t u r e s / c a t "
" P i c t u r e s / f r o m "
" P i c t u r e s / P h o t o s "
" P i c t u r e s / S c r e e n s h o t s "
2024-02-15 00:49:24 +00:00
" P i c t u r e s / s e r v o - m a c r o s "
2024-02-27 21:36:18 +00:00
" V i d e o s / l o c a l "
2024-02-15 00:49:24 +00:00
" V i d e o s / s e r v o "
" t m p "
] ;
2024-01-22 09:30:13 +00:00
2023-11-08 15:32:50 +00:00
persist . byStore . private = [ " . l o c a l / s h a r e / d i n o " ] ;
2023-09-21 19:40:12 +00:00
services . dino = {
2023-11-14 00:38:38 +00:00
description = " d i n o X M P P c l i e n t " ;
2024-03-21 16:02:06 +00:00
partOf = lib . mkIf cfg . config . autostart [ " g r a p h i c a l - s e s s i o n " ] ;
2024-02-19 12:57:44 +00:00
2024-03-21 05:13:48 +00:00
# audio buffering; see: <https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/FAQ#pipewire-buffering-explained>
# dino defaults to 10ms mic buffer, which causes underruns, which Dino handles *very* poorly
# as in, the other end of the call will just not receive sound from us for a couple seconds.
# pipewire uses power-of-two buffering for the mic itself. that would put us at 21.33 ms, but this env var supports only whole numbers (21ms ends up not power-of-two).
# also, Dino's likely still doing things in 10ms batches internally anyway.
#
2024-04-02 09:02:44 +00:00
# further: decrease the "niceness" of dino, so that it can take precedence over anything else.
# ideally this would target just the audio processing, rather than the whole program.
# pipewire is the equivalent of `nice -n -21`, so probably don't want to go any more extreme than that.
# nice -n -15 chosen arbitrarily; not optimized
#
2024-03-21 05:13:48 +00:00
# note that debug logging during calls produces so much journal spam that it pegs the CPU and causes dropped audio
# env G_MESSAGES_DEBUG = "all";
2024-04-02 09:02:44 +00:00
command = " e n v P U L S E _ L A T E N C Y _ M S E C = 2 0 n i c e - n - 1 5 d i n o " ;
2023-09-21 19:40:12 +00:00
} ;
} ;
2023-08-28 08:48:35 +00:00
}