From 369408f1274276c53860bd7a0197c770503995e5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 7 Jun 2015 23:07:55 +0200 Subject: Started work on trivmix service expressions --- custom/trivmix-service.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 custom/trivmix-service.nix (limited to 'custom/trivmix-service.nix') diff --git a/custom/trivmix-service.nix b/custom/trivmix-service.nix new file mode 100644 index 00000000..6fca4649 --- /dev/null +++ b/custom/trivmix-service.nix @@ -0,0 +1,42 @@ +{ name +, run ? null +, connectOut ? null +, connectIn ? null +, trivmix +, stdenv +, makeWrapper +, jack2 +}: + +let + genRun = if ! isNull run then run else ( + "${derivRun}/run.sh" + ); + derivRun = stdenv.mkDerivation { + name = "trivmix-run"; + src = '' + #!/bin/sh + + ${if ! isNull connectIn then "jack_connect ${connectIn} $1" else ""} + ${if ! isNull connectOut then "jack_connect $2 ${connectOut}" else ""} + ''; + unpackPhase = "cat"; + buildInputs = [ makeWrapper ]; + buildPhase = '' + 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 { + wantedBy = [ "sound.target" ]; + requires = [ "jack.service" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${trivmix} --client ${name} --run ${genRun} --dir /run/${name}"; + User = "jack"; + Group = "audio"; + }; +} -- cgit v1.2.3