anchor.diff:      mkdir -p $out/app
       cp -r app/server $out/app/
   
  +    # We didn't build this during linux-prebuild.sh so copy from the separate derivation
  +    cp ${aubioonset}/aubioonset $out/app/server/native/
  +
       # Copy only necessary files for the gui app.
  -    mkdir -p $out/app/gui/qt/build
  +    mkdir -p $out/app/gui/qt
       cp -r app/gui/qt/{book,fonts,help,html,images,image_source,info,lang,theme} $out/app/gui/qt/
  -    cp app/gui/qt/build/sonic-pi $out/app/gui/qt/build/sonic-pi
  +    mkdir -p $out/app/build/gui/qt
  +    cp app/build/gui/qt/sonic-pi $out/app/build/gui/qt/sonic-pi
   
       runHook postInstall
     '';
  
positive.code:     aubio
      supercollider_single_prec
      boost
    ];
  
    dontUseCmakeConfigure = true;
  
    preConfigure = ''
      patchShebangs .
      substituteInPlace app/gui/qt/mainwindow.cpp \
        --subst-var-by ruby "${ruby}/bin/ruby" \
        --subst-var out
    '';
  
    buildPhase = ''
      export SONIC_PI_HOME=$TMPDIR
      export AUBIO_LIB=${aubio}/lib/libaubio.so
      export OSMID_DIR=app/server/native/osmid
  
      mkdir -p $OSMID_DIR
      cp ${osmid}/bin/{m2o,o2m} $OSMID_DIR
  
      pushd app/server/ruby/bin
        ./compile-extensions.rb
        ./i18n-tool.rb -t
      popd
  
      pushd app/gui/qt
        cp -f utils/ruby_help.tmpl utils/ruby_help.h
        ../../server/ruby/bin/qt-doc.rb -o utils/ruby_help.h
  
        lrelease lang/*.ts
  
        mkdir build
        pushd build
          cmake -G "Unix Makefiles" ..
          make
        popd
      popd
    '';
  
    installPhase = ''
  
negative.code:   dontWrapQtApps = true;
    preFixup = ''
      wrapQtApp "$out/bin/sonic-pi" \
        --prefix PATH : ${lib.makeBinPath [ bash jack2 ruby supercollider erlang] }
      makeWrapper \
        $out/app/server/ruby/bin/sonic-pi-server.rb \
        $out/bin/sonic-pi-server \
        --prefix PATH : ${lib.makeBinPath [ bash jack2 ruby supercollider erlang ] }
    '';
  
    meta = {
      homepage = "https://sonic-pi.net/";
      description = "Free live coding synth for everyone originally designed to support computing and music lessons within schools";
      license = lib.licenses.mit;
      maintainers = with lib.maintainers; [ Phlogistique kamilchm c0deaddict sohalt ];
      platforms = lib.platforms.linux;
    };
  }
  