{ name , run ? null , connectOut ? null , connectIn ? null , group ? null , trivmix , stdenv , makeWrapper , jack2 }: let genRun = if ! isNull run then run else ( "${derivRun}/bin/run.sh" ); derivRun = stdenv.mkDerivation { name = "trivmix-run"; src = builtins.toFile "run.sh" '' #!/bin/sh ${if ! isNull connectIn then "jack_connect ${connectIn} $1" else ""} ${if ! isNull connectOut then "jack_connect $2 ${connectOut}" else ""} ''; unpackPhase = "cat"; buildInputs = [ makeWrapper ]; installPhase = '' mkdir -p $out/bin cp $src $out/bin/run.sh chmod 755 $out/bin/run.sh wrapProgram $out/bin/run.sh \ --prefix PATH : ${jack2}/bin ''; }; in rec { out = { wantedBy = [ "sound.target" ]; requires = [ "jack.service" ]; serviceConfig = { Type = "simple"; ExecStart = "${trivmix}/bin/trivmix --client ${name} --run ${genRun} --level /dev/shm/mix/${name}/level${if ! isNull group then \" --dir /dev/shm/mix/${group}/level\" else \"\"}"; User = "jack"; Group = "audio"; }; }; }