Audio production: Difference between revisions

From NixOS Wiki
imported>Deifactor
document how to install VSTs
 
imported>Deifactor
update to be more generic about audio production
Line 1: Line 1:
== VSTs ==
[https://github.com/musnix/musnix Musnix] is useful for things like setting up ulimit values automatically.


VSTs go in either ~/.vst or ~/.vst3If using VSTs, they may depend on libraries that are not available in the Renoise path. This will show up in the logs as an error along the lines of
== Plugins not found ==


Vst3Plugs: Failed to load module: dlopen failed.
Due to NixOS not using FHS paths, many DAWs will not know where to look for VSTs and other plugins. Musnix fixes this; if you don't want to use it, you can solve this by setting
libSM.so.6: cannot open shared object file: No such file or directory


To solve this, you'll need to turn Renoise into a wrapper that adds the missing libraries to the LD_LIBRARY_PATH:
<syntaxhighlight lang="nix">
    environment.variables = let
      makePluginPath = format:
        (makeSearchPath format [
          "$HOME/.nix-profile/lib"
          "/run/current-system/sw/lib"
          "/etc/profiles/per-user/$USER/lib"
        ])
        + ":$HOME/.${format}";
    in {
      DSSI_PATH  = makePluginPath "dssi";
      LADSPA_PATH = makePluginPath "ladspa";
      LV2_PATH    = makePluginPath "lv2";
      LXVST_PATH  = makePluginPath "lxvst";
      VST_PATH    = makePluginPath "vst";
      VST3_PATH  = makePluginPath "vst3";
    };
</syntaxhighlight>
 
Some programs may not support those and may require other means of setting VST paths.
 
== Packaging plugins ==
 
Source-available plugins can be packaged like any other library; note that the output files should wind up in <code>$out/lib/vst3</code>.
 
If the plugin is only available as a binary, you may need to use [[Packaging/Binaries|the advice on packaging binaries]] to help. Since many plugins will not be accessible via the standard fetchers, you can always fall back on including the plugin using <code>src = ./plugin.zip</code>; note that if you're using flakes and don't want to commit the plugin to Git (an especially bad idea if your config is public!), you can use requireFile and manually add files to the store. To do this, run <code>nix-hash --flat --type sha256 plugin.zip</code>, take the output, and use it in a derivation like so:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
let
      src = requireFile {
  vstLibs = with pkgs; [
        message = "run nix-store add-file";
    # your libraries go here
        name = "plugin.zip";
  ];
         sha256 =
  renoiseWithVsts = with pkgs;
           "68f3c7e845f3d7a5b44a83adeb6e34ef221503df00e7964f7d5a1f132a252d13";
    renoise.overrideAttrs (prev: {
       };
      nativeBuildInputs = [ makeWrapper ];
      # keep the existing postFixup script as well
      postFixup = prev.postFixup + ''
         wrapProgram $out/bin/renoise \
           --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath vstLibs}"
       '';
    });
in
  environment.systemPackages = [
    renoiseWithVsts
    # your other packages
  ];
</syntaxhighlight>
</syntaxhighlight>


To figure out what libraries you need, run {{ic|ldd path/to/your/vst.so | grep "not found"}}; ignore the warning about not having executable permissions if you get it. You'll get something like
Then run <code>nix-store add-file plugin.zip</code>.


<pre>
As an example, a working package for Vital looks like
libasound.so.2 => not found
libSM.so.6 => not found
libICE.so.6 => not found
libX11.so.6 => not found
libXext.so.6 => not found
libGL.so.1 => not found
libfreetype.so.6 => not found
libstdc++.so.6 => not found
</pre>
 
Anything that already shows up in {{ic|ldd $(which renoise) | grep "=>" | cut -d' ' -f1}} will already be loaded by Renoise itself. In this case, we can see we need libSM, libICE, libXext, libGL, and libfreetype. Using [https://github.com/nix-community/nix-index nix-index], we can find the corresponding packages are


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
   vstLibs = with pkgs; [
stdenv.mkDerivation rec {
   pname = "vital";
  version = "1.5.5";
  src = requireFile {
    message = "run nix-store add-file VitalInstaller.zip";
    name = "VitalInstaller.zip";
    # this may be different for you!
    sha256 =
      "68f3c7e845f3d7a5b44a83adeb6e34ef221503df00e7964f7d5a1f132a252d13";
  };
  nativeBuildInputs = [ makeWrapper unzip ];
  buildInputs = [
    alsa-lib
    freetype
    libglvnd
    stdenv.cc.cc.lib
    xorg.libICE
     xorg.libSM
     xorg.libSM
     xorg.libICE
     xorg.libX11
     xorg.libXext
     xorg.libXext
    freetype
    libGL
   ];
   ];
  unpackPhase = ''
    unzip $src
  '';
  installPhase = ''
    mkdir -p $out
    cp -r VitalInstaller/lib $out/lib
  '';
  postFixup = ''
    for file in \
      $out/lib/clap/Vital.clap \
      $out/lib/vst/Vital.so \
      $out/lib/vst3/Vital.vst3/Contents/x86_64-linux/Vital.so
    do
      patchelf --set-rpath "${lib.makeLibraryPath buildInputs}" $file
    done
  '';
};
</syntaxhighlight>
</syntaxhighlight>

Revision as of 05:31, 17 October 2023

Musnix is useful for things like setting up ulimit values automatically.

Plugins not found

Due to NixOS not using FHS paths, many DAWs will not know where to look for VSTs and other plugins. Musnix fixes this; if you don't want to use it, you can solve this by setting

    environment.variables = let
      makePluginPath = format:
        (makeSearchPath format [
          "$HOME/.nix-profile/lib"
          "/run/current-system/sw/lib"
          "/etc/profiles/per-user/$USER/lib"
        ])
        + ":$HOME/.${format}";
    in {
      DSSI_PATH   = makePluginPath "dssi";
      LADSPA_PATH = makePluginPath "ladspa";
      LV2_PATH    = makePluginPath "lv2";
      LXVST_PATH  = makePluginPath "lxvst";
      VST_PATH    = makePluginPath "vst";
      VST3_PATH   = makePluginPath "vst3";
    };

Some programs may not support those and may require other means of setting VST paths.

Packaging plugins

Source-available plugins can be packaged like any other library; note that the output files should wind up in $out/lib/vst3.

If the plugin is only available as a binary, you may need to use the advice on packaging binaries to help. Since many plugins will not be accessible via the standard fetchers, you can always fall back on including the plugin using src = ./plugin.zip; note that if you're using flakes and don't want to commit the plugin to Git (an especially bad idea if your config is public!), you can use requireFile and manually add files to the store. To do this, run nix-hash --flat --type sha256 plugin.zip, take the output, and use it in a derivation like so:

      src = requireFile {
        message = "run nix-store add-file";
        name = "plugin.zip";
        sha256 =
          "68f3c7e845f3d7a5b44a83adeb6e34ef221503df00e7964f7d5a1f132a252d13";
      };

Then run nix-store add-file plugin.zip.

As an example, a working package for Vital looks like

stdenv.mkDerivation rec {
  pname = "vital";
  version = "1.5.5";
  src = requireFile {
    message = "run nix-store add-file VitalInstaller.zip";
    name = "VitalInstaller.zip";
    # this may be different for you!
    sha256 =
      "68f3c7e845f3d7a5b44a83adeb6e34ef221503df00e7964f7d5a1f132a252d13";
  };
  nativeBuildInputs = [ makeWrapper unzip ];
  buildInputs = [
    alsa-lib
    freetype
    libglvnd
    stdenv.cc.cc.lib
    xorg.libICE
    xorg.libSM
    xorg.libX11
    xorg.libXext
  ];

  unpackPhase = ''
    unzip $src
  '';

  installPhase = ''
    mkdir -p $out
    cp -r VitalInstaller/lib $out/lib 
  '';
  postFixup = ''
    for file in \
      $out/lib/clap/Vital.clap \
      $out/lib/vst/Vital.so \
      $out/lib/vst3/Vital.vst3/Contents/x86_64-linux/Vital.so
    do
      patchelf --set-rpath "${lib.makeLibraryPath buildInputs}" $file
    done
  '';
};