about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <git@lukasepple.de>2020-07-22 02:49:00 +0200
committersternenseemann <git@lukasepple.de>2020-07-22 02:49:00 +0200
commitda40f251c5f884c642b86f13b6d7ed6333eceeb4 (patch)
tree3a0edcc5ae2b52dba4c45046d952d89ac34947a8
parentea4bd2ee5bad2d2d24cd77d901911c249df5ab3f (diff)
Add likely-music pkg (wrapped backend with all deps resolved)
use makeWrapper to wrap likely-music-backend and
add the necessesary env vars:

* LIKELY_MUSIC_FRONTEND points to likely-music-frontend
* LIKELY_MUSIC_SYNTH points to a wrapper script around fluidsynth
  which accepts just the two necessary options and has soundfont-fluid
  set up properly.
-rw-r--r--pkgs.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkgs.nix b/pkgs.nix
index ea69904..c1f6f06 100644
--- a/pkgs.nix
+++ b/pkgs.nix
@@ -6,4 +6,30 @@ rec {
   likely-music-backend = pkgs.haskellPackages.callPackage ./likely-music-backend.nix { };
 
   likely-music-frontend = pkgs.callPackage ./web { };
+
+  # executable wrapper around everything with correct paths
+  likely-music = pkgs.runCommand "likely-music" { } ''
+    mkdir -p $out/bin
+    source "${pkgs.dieHook}/nix-support/setup-hook"
+    source "${pkgs.makeWrapper}/nix-support/setup-hook"
+    makeWrapper "${likely-music-backend}/bin/likely-music-backend" "$out/bin/likely-music" \
+      --argv0 likely-music \
+      --set LIKELY_MUSIC_FRONTEND "${likely-music-frontend}/share/likely-music-frontend" \
+      --set LIKELY_MUSIC_SYNTH "${fluidsynth-wrapper}/bin/fluidsynth-wrapper"
+    '';
+
+  fluidsynth-wrapper = pkgs.writeTextFile {
+    name = "fluidsynth-wrapper";
+    executable = true;
+    destination = "/bin/fluidsynth-wrapper";
+    text = ''
+      #!${pkgs.bash}/bin/bash
+      # fluidsynth-wrapper IN.mid OUT.wav
+      if [ -z "$1" -o -z "$2" ]; then
+        echo "$0: missing file parameter(s)" >&2
+        exit 1
+      fi
+      ${pkgs.fluidsynth}/bin/fluidsynth -a file -i ${pkgs.soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2 -F "$2" "$1"
+    '';
+  };
 }