Skip to content

Commit

Permalink
nixos/mediagoblin: fix media reprocessing with gmg
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Dec 7, 2024
1 parent df9ca79 commit a92203a
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions nixos/modules/services/web-apps/mediagoblin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,32 @@ let

iniFormat = pkgs.formats.ini { };

# we need to build our own GI_TYPELIB_PATH because celery and paster need this information, too and cannot easily be re-wrapped
GI_TYPELIB_PATH =
# we need to build our own GI_TYPELIB_PATH and GST_PLUGIN_PATH because celery, paster and gmg need this information and it cannot easily be re-wrapped
gst =
let
needsGst =
(cfg.settings.mediagoblin.plugins ? "mediagoblin.media_types.audio")
|| (cfg.settings.mediagoblin.plugins ? "mediagoblin.media_types.video");
in
lib.makeSearchPathOutput "out" "lib/girepository-1.0" (
with pkgs.gst_all_1;
[
pkgs.glib
gst-plugins-base
gstreamer
]
# audio and video share most dependencies, so we can just take audio
++ lib.optionals needsGst cfg.package.optional-dependencies.audio
++ lib.optionals needsGst cfg.package.optional-dependencies.audio;
GI_TYPELIB_PATH = lib.makeSearchPathOutput "out" "lib/girepository-1.0" gst;
GST_PLUGIN_PATH = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" gst;

path =
lib.optionals (cfg.settings.mediagoblin.plugins ? "mediagoblin.media_types.stl") [ pkgs.blender ]
++ lib.optionals (cfg.settings.mediagoblin.plugins ? "mediagoblin.media_types.pdf") (
with pkgs;
[
poppler_utils
unoconv
]
);

finalPackage = cfg.package.python.buildEnv.override {
Expand Down Expand Up @@ -189,7 +199,7 @@ in
if [[ "$USER" != mediagoblin ]]; then
sudo='exec /run/wrappers/bin/sudo -u mediagoblin'
fi
$sudo sh -c "cd /var/lib/mediagoblin; env GI_TYPELIB_PATH=${GI_TYPELIB_PATH} ${lib.getExe' finalPackage "gmg"} $(printf -- '%s ' "$@")"
$sudo sh -c "cd /var/lib/mediagoblin; env GI_TYPELIB_PATH=${GI_TYPELIB_PATH} GST_PLUGIN_PATH=${GST_PLUGIN_PATH} PATH=$PATH:${lib.concatStringsSep ":" path} ${lib.getExe' finalPackage "gmg"} $(printf -- '%s ' "$@")"
'')
];

Expand Down Expand Up @@ -247,15 +257,7 @@ in
let
serviceDefaults = {
wantedBy = [ "multi-user.target" ];
path =
lib.optionals (cfg.settings.mediagoblin.plugins ? "mediagoblin.media_types.stl") [ pkgs.blender ]
++ lib.optionals (cfg.settings.mediagoblin.plugins ? "mediagoblin.media_types.pdf") (
with pkgs;
[
poppler_utils
unoconv
]
);
inherit path;
serviceConfig = {
AmbientCapabilities = "";
CapabilityBoundingSet = [ "" ];
Expand Down Expand Up @@ -324,6 +326,7 @@ in
Environment = [
"CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery"
"GI_TYPELIB_PATH=${GI_TYPELIB_PATH}"
"GST_PLUGIN_PATH=${GST_PLUGIN_PATH}"
"MEDIAGOBLIN_CONFIG=/var/lib/mediagoblin/mediagoblin.ini"
"PASTE_CONFIG=${pasteConfig}"
];
Expand All @@ -349,6 +352,7 @@ in
Environment = [
"CELERY_ALWAYS_EAGER=false"
"GI_TYPELIB_PATH=${GI_TYPELIB_PATH}"
"GST_PLUGIN_PATH=${GST_PLUGIN_PATH}"
];
ExecStart = "${lib.getExe' finalPackage "paster"} serve /var/lib/mediagoblin/paste.ini";
};
Expand Down

0 comments on commit a92203a

Please sign in to comment.