summaryrefslogtreecommitdiff
path: root/custom/trivmix-service.nix
diff options
context:
space:
mode:
Diffstat (limited to 'custom/trivmix-service.nix')
-rw-r--r--custom/trivmix-service.nix41
1 files changed, 19 insertions, 22 deletions
diff --git a/custom/trivmix-service.nix b/custom/trivmix-service.nix
index 3c3cded7..e9120f88 100644
--- a/custom/trivmix-service.nix
+++ b/custom/trivmix-service.nix
@@ -3,43 +3,40 @@
3, connectOut ? null 3, connectOut ? null
4, connectIn ? null 4, connectIn ? null
5, group ? null 5, group ? null
6, initial ? null
6, trivmix 7, trivmix
7, stdenv 8, stdenv
8, makeWrapper 9, makeWrapper
9, jack2Full 10, jack2Full
10, coreutils 11, coreutils
12, writeScript
11}: 13}:
12 14
13let 15let
14 genRun = if ! isNull run then run else ( 16 connect = (! isNull connectOut) || (! isNull connectIn);
15 "${derivRun}/bin/run.sh" 17 connectScript = writeScript "connect" ''
16 ); 18 #!${stdenv.shell}
17 derivRun = stdenv.mkDerivation {
18 name = "trivmix-run";
19 src = builtins.toFile "run.sh" ''
20 #!/bin/sh
21 19
22 ${if ! isNull connectIn then "jack_connect ${connectIn} $1" else ""} 20 PATH=${jack2Full}/bin:$PATH
23 ${if ! isNull connectOut then "jack_connect $2 ${connectOut}" else ""} 21
24 ''; 22 ${optionalString (! isNull connectIn) "jack_connect ${connectIn} $1"}
25 unpackPhase = "cat"; 23 ${optionalString (! isNull connectOut) "jack_connect $2 ${connectOut}"}
26 buildInputs = [ makeWrapper ]; 24 '';
27 installPhase = '' 25 inherit (stdenv.lib) optionalString;
28 mkdir -p $out/bin 26in {
29 cp $src $out/bin/run.sh
30 chmod 755 $out/bin/run.sh
31 wrapProgram $out/bin/run.sh \
32 --prefix PATH : ${jack2Full}/bin
33 '';
34 };
35in rec {
36 out = { 27 out = {
37 wantedBy = [ "sound.target" ]; 28 wantedBy = [ "sound.target" ];
38 requires = [ "jack.service" ]; 29 requires = [ "jack.service" ];
39 before = [ "mpd.service" ]; 30 before = [ "mpd.service" ];
40 serviceConfig = { 31 serviceConfig = {
41 Type = "simple"; 32 Type = "simple";
42 ExecStart = ''${trivmix}/bin/trivmix --client ${name} --run ${genRun} /dev/shm/mix/${name}/level${if ! isNull group then " /dev/shm/mix/${group}/level" else ""}''; 33 ExecStart = ''${trivmix}/bin/trivmix --client ${name} \
34 ${optionalString connect "--run ${connectScript}"} \
35 ${optionalString (! isNull run) "--run ${run}"} \
36 ${optionalString (! isNull initial) "--level ${initial}"} \
37 /dev/shm/mix/${name}/level \
38 ${optionalString (! isNull group) "/dev/shm/mix/${group}/level"}
39 '';
43 User = "jack"; 40 User = "jack";
44 Group = "audio"; 41 Group = "audio";
45 Nice = "-10"; 42 Nice = "-10";