How to access user-environment path in config

Is there any way to get the user-environment path in the config. The path looks like /nix/store/ypn6z330a616r0f6hd1pi8lika3qap5v-user-environment.

I need it for a script to launch obs-studio with all of its plugins. I tried ${lib.getBin pkgs.obs-studio} and ${pkgs.obs-studio}/bin/obs, but both of them gives me a path like /nix/store/5al3i84hh5nnybz04hjks4vdya48kvkb-obs-studio-30.1.2/bin/obs that does not load the plugins that I added to my config.

To launch obs properly, I need to have a path like : /nix/store/ypn6z330a616r0f6hd1pi8lika3qap5v-user-environment/bin/obs.

Try using lib.getExe, it might work.

1 Like

Same thing, ${lib.getExe pkgs.obs-studio} gives me /nix/store/5al3i84hh5nnybz04hjks4vdya48kvkb-obs-studio-30.1.2/bin/obs

You don’t have to do that if you just want to load obs with plugins. Instead, you can choose one of the two methods from the OBS Studio - NixOS Wiki page.

1 Like

I already installed the plugins using home manager like that

programs.obs-studio = {
  enable = true;
  plugins = with pkgs.obs-studio-plugins; [
    obs-vkcapture # to record fullscreen window only
    obs-websocket # for obs-cmd
  ];
};

But the plugins are loaded in the user-environment executable. Here is the output of /nix/store/ypn6z330a616r0f6hd1pi8lika3qap5v-user-environment/bin/obs

#! /nix/store/5jw69mbaj5dg4l2bj58acg3gxywfszpj-bash-5.2p26/bin/bash -e
export OBS_PLUGINS_PATH='/nix/store/1rwm6l5pm9padh6kxmdp4wd6xczhrnzb-obs-studio-plugins/lib/obs-plugins'
export OBS_PLUGINS_DATA_PATH='/nix/store/1rwm6l5pm9padh6kxmdp4wd6xczhrnzb-obs-studio-plugins/share/obs/obs-plugins'
exec -a "$0" "/nix/store/ijp18z8q0n5gvv1a1lwgriylkdnhpdpl-wrapped-obs-studio-30.1.2/bin/.obs-wrapped_"  "$@"

You can see that it loads plugins here

With the caveat that I haven’t used hm, it looks like the obs module has a hidden finalPackage attr that you may be able to use.

If not, I would suggest following the same approach the module uses to construct an obs with plugins:

2 Likes

Thanks a lot !!! Using ${config.programs.obs-studio.finalPackage} is indeed the right way. I can now launch obs in a script with all of its plugins.

1 Like