blob: 3c3cded756feccf4b2ad696bb94d92ea3f82329c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
{ name
, run ? null
, connectOut ? null
, connectIn ? null
, group ? null
, trivmix
, stdenv
, makeWrapper
, jack2Full
, coreutils
}:
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 : ${jack2Full}/bin
'';
};
in rec {
out = {
wantedBy = [ "sound.target" ];
requires = [ "jack.service" ];
before = [ "mpd.service" ];
serviceConfig = {
Type = "simple";
ExecStart = ''${trivmix}/bin/trivmix --client ${name} --run ${genRun} /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";
};
};
}
|