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 --- bragi.nix | 3 +++ custom/trivmix-service.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 custom/trivmix-service.nix diff --git a/bragi.nix b/bragi.nix index 8376d70a..bf05dcfa 100644 --- a/bragi.nix +++ b/bragi.nix @@ -93,6 +93,9 @@ }; }; + systemd.services."mpdmix0" = pkgs.callPackage ./custom/trivmix-service { name = "mpdmix0"; connectOut = "system:playback_3"; }; + systemd.services."mpdmix1" = pkgs.callPackage ./custom/trivmix-service { name = "mpdmix1"; connectOut = "system:playback_4"; }; + services.mpd = { enable = true; 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 @@ +{ 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