From 0631b6b91d79c55a4b3527719c6dc6b851369f3c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 9 Mar 2017 13:52:21 +0100 Subject: Bump trivmix --- custom/trivmix | 2 +- custom/trivmix-service.nix | 59 ++++++++++++++++++++-------------------------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/custom/trivmix b/custom/trivmix index 6454da50..2f5f8801 160000 --- a/custom/trivmix +++ b/custom/trivmix @@ -1 +1 @@ -Subproject commit 6454da50559e0eee810f81d33365a621857d8068 +Subproject commit 2f5f880136f3411e7e8d919631e71ef05d0ae9ad diff --git a/custom/trivmix-service.nix b/custom/trivmix-service.nix index 5e0e5b47..56b26b6f 100644 --- a/custom/trivmix-service.nix +++ b/custom/trivmix-service.nix @@ -9,44 +9,35 @@ , makeWrapper , jack2Full , coreutils +, writeScript }: 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 + connect = (! isNull connectOut) || (! isNull connectIn); + connectScript = writeScript "connect" '' + #!${stdenv.shell} - ${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 : ${jack2Full}/bin - ''; - }; + ${optionalString (! isNull connectIn) "jack_connect ${connectIn} $1"} + ${optionalString (! isNull connectOut) "jack_connect $2 ${connectOu}"} + ''; inherit (stdenv.lib) optionalString; -in rec { - out = { - wantedBy = [ "sound.target" ]; - requires = [ "jack.service" ]; - before = [ "mpd.service" ]; - serviceConfig = { - Type = "simple"; - ExecStart = ''${trivmix}/bin/trivmix --client ${name} --run ${genRun}${optionalString (initial != null) " --level ${initial}"} /dev/shm/mix/${name}/level${if ! isNull group then " /dev/shm/mix/${group}/level" else ""}''; - User = "jack"; - Group = "audio"; - Nice = "-10"; - LimitRTPRIO = "95:95"; - LimitMEMLOCK = "infinity"; - }; +in { + wantedBy = [ "sound.target" ]; + requires = [ "jack.service" ]; + before = [ "mpd.service" ]; + serviceConfig = { + Type = "simple"; + ExecStart = ''${trivmix}/bin/trivmix --client ${name} \ + ${optionalString connect "--run ${connectScript}"} \ + ${optionalString (! isNull run) "--run ${run}"} \ + ${optionalString (! isNull initial) "--level ${initial}"} \ + /dev/shm/mix/${name}/level \ + ${optionalString (! isNull group) "/dev/shm/mix/${group}/level"} + ''; + User = "jack"; + Group = "audio"; + Nice = "-10"; + LimitRTPRIO = "95:95"; + LimitMEMLOCK = "infinity"; }; } -- cgit v1.2.3