lemmy: port to new pict-rs and enable video

This commit is contained in:
Colin 2023-08-20 05:00:35 +00:00
parent c8a3814f6a
commit 0edab7ed64

View File

@ -3,13 +3,23 @@
# - <repo:LemmyNet/lemmy:docker/nginx.conf>
# - <repo:LemmyNet/lemmy-ansible:templates/nginx.conf>
{ 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: <https://git.asonix.dog/asonix/pict-rs/src/branch/main/pict-rs.toml>
# 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: <https://git.asonix.dog/asonix/pict-rs#user-content-running>
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
]);
}