Trying to contribute to nixpkgs but only buildFHSEnv works for binary

I believe I have finally solved this issue completely and here is the fully completed package ready for nixpkgs (and I believe it is pretty simple and clean solution):

# default.nix
{ lib
, stdenv
, fetchzip
, buildFHSEnv
, alsa-lib
, freetype
, nghttp2
, xorg
, }:

let
  pname = "decent-sampler";
  version = "1.9.4";

  decent-sampler = stdenv.mkDerivation {
    inherit pname version;

    src = fetchzip {
      # dropbox link: https://www.dropbox.com/sh/dwyry6xpy5uut07/AABBJ84bjTTSQWzXGG5TOQpfa\

      # Internet Archive should be more reliable
      url = "https://archive.org/download/decent-sampler-linux-static-download-mirror/Decent_Sampler-${version}-Linux-Static-x86_64.tar.gz";
      sha256 = "sha256-O/0R70tZOmSGgth6nzt4zPiJr1P8890uzk8PiQGnC6M=";
    };

    installPhase = ''
      mkdir -p $out/bin
      install -m755 -D DecentSampler $out/bin/
    '';

  };
in

buildFHSEnv {
  name = pname;

  targetPkgs = pkgs: [
    decent-sampler
    alsa-lib
    freetype
    nghttp2
    xorg.libX11
  ];

  runScript = "DecentSampler";

  meta = with lib; {
    description = "An audio sample player";
    longDescription = ''
        Decent Sampler is an audio sample player.
        Allowing you to play sample libraries in the DecentSampler format
        (files with extensions: dspreset and dslibrary).
        It claims to be free but we currently cannot find any license
        that it is released under.
    '';
    homepage = "https://www.decentsamples.com/product/decent-sampler-plugin/";
    license = licenses.unlicense;
    platforms = platforms.linux;
    maintainers = with maintainers; [ adam248 ];
  };
}

There were so many complex examples out there that were really hard to wrap my head around but in the end my package is now the simplest example of how to use buildFHSUserEnv (aka buildFHSEnv) to make a package in nixpkgs.

I plan to update it later to enable the linking of the vst and vst3 plugins for use with Reaper and other such DAWs later.

Please let me know if this has helped anyone elseā€¦

1 Like