diff options
-rw-r--r-- | bragi.nix | 3 | ||||
-rw-r--r-- | custom/trivmix-service.nix | 42 |
2 files changed, 45 insertions, 0 deletions
@@ -93,6 +93,9 @@ | |||
93 | }; | 93 | }; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | systemd.services."mpdmix0" = pkgs.callPackage ./custom/trivmix-service { name = "mpdmix0"; connectOut = "system:playback_3"; }; | ||
97 | systemd.services."mpdmix1" = pkgs.callPackage ./custom/trivmix-service { name = "mpdmix1"; connectOut = "system:playback_4"; }; | ||
98 | |||
96 | services.mpd = { | 99 | services.mpd = { |
97 | enable = true; | 100 | enable = true; |
98 | musicDirectory = "/media/odin/music"; | 101 | musicDirectory = "/media/odin/music"; |
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 @@ | |||
1 | { name | ||
2 | , run ? null | ||
3 | , connectOut ? null | ||
4 | , connectIn ? null | ||
5 | , trivmix | ||
6 | , stdenv | ||
7 | , makeWrapper | ||
8 | , jack2 | ||
9 | }: | ||
10 | |||
11 | let | ||
12 | genRun = if ! isNull run then run else ( | ||
13 | "${derivRun}/run.sh" | ||
14 | ); | ||
15 | derivRun = stdenv.mkDerivation { | ||
16 | name = "trivmix-run"; | ||
17 | src = '' | ||
18 | #!/bin/sh | ||
19 | |||
20 | ${if ! isNull connectIn then "jack_connect ${connectIn} $1" else ""} | ||
21 | ${if ! isNull connectOut then "jack_connect $2 ${connectOut}" else ""} | ||
22 | ''; | ||
23 | unpackPhase = "cat"; | ||
24 | buildInputs = [ makeWrapper ]; | ||
25 | buildPhase = '' | ||
26 | mkdir -p $out/bin | ||
27 | cp $src $out/bin/run.sh | ||
28 | chmod 755 $out/bin/run.sh | ||
29 | wrapProgram $out/bin/run.sh \ | ||
30 | --prefix PATH : ${jack2}/bin | ||
31 | ''; | ||
32 | }; | ||
33 | in { | ||
34 | wantedBy = [ "sound.target" ]; | ||
35 | requires = [ "jack.service" ]; | ||
36 | serviceConfig = { | ||
37 | Type = "simple"; | ||
38 | ExecStart = "${trivmix} --client ${name} --run ${genRun} --dir /run/${name}"; | ||
39 | User = "jack"; | ||
40 | Group = "audio"; | ||
41 | }; | ||
42 | } | ||