From 0edab7ed648b2bd504030a37dcbd29d7793f96b7 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 20 Aug 2023 05:00:35 +0000 Subject: [PATCH] lemmy: port to new pict-rs and enable video --- hosts/by-name/servo/services/lemmy.nix | 41 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/hosts/by-name/servo/services/lemmy.nix b/hosts/by-name/servo/services/lemmy.nix index 1e9e931f..e91cf71f 100644 --- a/hosts/by-name/servo/services/lemmy.nix +++ b/hosts/by-name/servo/services/lemmy.nix @@ -3,13 +3,23 @@ # - # - -{ config, lib, ... }: +{ config, lib, pkgs, ... }: let inherit (builtins) toString; inherit (lib) mkForce; uiPort = 1234; # default ui port is 1234 backendPort = 8536; # default backend port is 8536 - # - i guess the "backend" port is used for federation? + #^ i guess the "backend" port is used for federation? + pict-rs = pkgs.pict-rs.overrideAttrs (upstream: { + # as of v 0.4.2, all non-GIF video is forcibly transcoded. + # that breaks lemmy, because of the request latency. + # and it eats up hella CPU. + # pict-rs is iffy around video altogether: mp4 seems the best supported. + postPatch = (upstream.postPatch or "") + '' + substituteInPlace src/validate.rs \ + --replace 'if transcode_options.needs_reencode() {' 'if false {' + ''; + }); in { services.lemmy = { enable = true; @@ -56,4 +66,31 @@ in { }; sane.dns.zones."uninsane.org".inet.CNAME."lemmy" = "native"; + + #v DO NOT REMOVE: defaults to 0.3, instead of latest, so always need to explicitly set this. + services.pict-rs.package = pict-rs; + # pict-rs configuration is applied in this order: + # - via toml + # - via env vars (overrides everything above) + # - via CLI flags (overrides everything above) + # some of the CLI flags have defaults, making it the only actual way to configure certain things even when docs claim otherwise. + systemd.services.pict-rs.environment = { + # lemmy's media-hosting service + # docs: + + # PICTRS__MEDIA__VIDEO__ENABLE = "1"; # enable webm and mp4 + # PICTRS__MEDIA__VIDEO__ALLOW_AUDIO = "1"; + # PICTRS__MEDIA__VIDEO__MAX_FRAME_COUNT = builtins.toString (30*60*60); # ~ 1 hr + # PICTRS__REPO__CACHE_CAPACITY = builtins.toString (128*1024*1024); # default is 64 MiB, but RAM is cheap here + + # PICTRS__MEDIA__SKIP_VALIDATE_IMPORTS = "1"; # to disable media validation + # PICTRS__OLD_DB__PATH = config.services.pict-rs.dataDir; #< needed only for 0.3 -> 0.4 migration + }; + # CLI args: + systemd.services.pict-rs.serviceConfig.ExecStart = lib.mkForce (lib.concatStringsSep " " [ + "${lib.getBin pict-rs}/bin/pict-rs run" + "--media-max-frame-count" (builtins.toString (30*60*60)) + "--media-process-timeout 120" + "--media-enable-full-video true" # allow audio + ]); }