about summary refs log tree commit diff
path: root/pkgs/applications/video/obs-studio/wrapper.nix
blob: 62bc80d26df3bc7afa6d8c928b63e98c03bad710 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ lib, obs-studio, symlinkJoin, makeWrapper }:

{ plugins ? [] }:

symlinkJoin {
  name = "wrapped-${obs-studio.name}";

  nativeBuildInputs = [ makeWrapper ];
  paths = [ obs-studio ] ++ plugins;

  postBuild = with lib;
    let
      # Some plugins needs extra environment, see obs-gstreamer for an example.
      pluginArguments =
        lists.concatMap (plugin: plugin.obsWrapperArguments or []) plugins;

      pluginsJoined = symlinkJoin {
        name = "obs-studio-plugins";
        paths = plugins;
      };

      wrapCommandLine = [
          "wrapProgram"
          "$out/bin/obs"
          ''--set OBS_PLUGINS_PATH "${pluginsJoined}/lib/obs-plugins"''
          ''--set OBS_PLUGINS_DATA_PATH "${pluginsJoined}/share/obs/obs-plugins"''
        ] ++ lists.unique pluginArguments;
    in ''
    ${concatStringsSep " " wrapCommandLine}

    # Remove unused obs-plugins dir to not cause confusion
    rm -r $out/share/obs/obs-plugins
    # Leave some breadcrumbs
    echo 'Plugins are at ${pluginsJoined}/share/obs/obs-plugins' > $out/share/obs/obs-plugins-README
  '';

  inherit (obs-studio) meta;
  passthru = obs-studio.passthru // {
    passthru.unwrapped = obs-studio;
  };
}