{ final, prev, ... }:
{
  libdscp = prev.stdenv.mkDerivation {
    pname = "libdscp";
    version = "0.0.0";

    src = ./src;

    makeFlags = [ "PREFIX=$(out)" ];
  };

  dscp = prev.writeShellApplication {
    name = "dscp";

    text = ''
      export LD_PRELOAD
      LD_PRELOAD=''${LD_PRELOAD:+':'$LD_PRELOAD':'}
      if [[ $LD_PRELOAD != *':'''${final.libdscp}/lib/libdscp.so''':'* ]]; then
          LD_PRELOAD='${final.libdscp}/lib/libdscp.so'$LD_PRELOAD
      fi
      LD_PRELOAD=''${LD_PRELOAD#':'}
      LD_PRELOAD=''${LD_PRELOAD%':'}

      : "''${DSCP:=0}"

      exec -- "$@"
    '';
  };
}