Skip to content

Commit

Permalink
Merge pull request #163935 from Sohalt/sonic-pi-3.3.1
Browse files Browse the repository at this point in the history
sonic-pi: 3.2.2 -> 3.3.1
  • Loading branch information
Lassulus authored Mar 22, 2022
2 parents 1c77127 + 8dc6d0d commit 9e5d59a
Showing 1 changed file with 58 additions and 40 deletions.
98 changes: 58 additions & 40 deletions pkgs/applications/audio/sonic-pi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,56 @@
, fetchFromGitHub
, fftwSinglePrec
, ruby
, erlang
, aubio
, alsa-lib
, rtmidi
, libsndfile
, cmake
, pkg-config
, boost
, bash
, jack2
, supercollider
, qwt
, osmid
}:

let

supercollider_single_prec = supercollider.override { fftw = fftwSinglePrec; };

in

mkDerivation rec {
version = "3.2.2";
pname = "sonic-pi";

version = "3.3.1";
src = fetchFromGitHub {
owner = "samaaron";
owner = "sonic-pi-net";
repo = "sonic-pi";
rev = "v${version}";
sha256 = "1nlkpkpg9iz2hvf5pymvk6lqhpdpjbdrvr0hrnkc3ymj7llvf1cm";
sha256 = "sha256-AE7iuSNnW1SAtBMplReGzXKcqD4GG23i10MIAWnlcPo=";
};

# sonic pi uses it's own aubioonset with hardcoded parameters but will compile a whole aubio for it
# let's just build the aubioonset instead and link against aubio from nixpkgs
aubioonset = mkDerivation {
name = "aubioonset";
src = src;
sourceRoot = "source/app/external/aubio/examples";
buildInputs = [jack2 aubio libsndfile];
patchPhase = ''
sed -i "s@<aubio.h>@<aubio/aubio.h>@" jackio.c utils.h
'';
buildPhase = ''
gcc -o aubioonset -laubio jackio.c utils.c aubioonset.c
'';
installPhase = ''
install -D aubioonset $out/aubioonset
'';
};

in

mkDerivation rec {
inherit pname version src;

buildInputs = [
bash
cmake
Expand All @@ -42,42 +64,36 @@ mkDerivation rec {
aubio
supercollider_single_prec
boost
erlang
alsa-lib
rtmidi
];

dontUseCmakeConfigure = true;

preConfigure = ''
patchShebangs .
substituteInPlace app/gui/qt/mainwindow.cpp \
--subst-var-by ruby "${ruby}/bin/ruby" \
--subst-var out
prePatch = ''
sed -i '/aubio/d' app/external/linux_build_externals.sh
sed -i '/aubio/d' app/linux-prebuild.sh
patchShebangs app
'';

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
configurePhase = ''
runHook preConfigure
pushd app/server/ruby/bin
./compile-extensions.rb
./i18n-tool.rb -t
popd
./app/linux-prebuild.sh
./app/linux-config.sh
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
runHook postConfigure
'';

lrelease lang/*.ts
buildPhase = ''
runHook preBuild
mkdir build
pushd build
cmake -G "Unix Makefiles" ..
make
popd
pushd app/build
cmake --build . --config Release
popd
runHook postBuild
'';

installPhase = ''
Expand All @@ -90,10 +106,14 @@ mkDerivation rec {
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
'';
Expand All @@ -102,20 +122,18 @@ mkDerivation rec {
dontWrapQtApps = true;
preFixup = ''
wrapQtApp "$out/bin/sonic-pi" \
--prefix PATH : ${lib.makeBinPath [ bash jack2 ruby supercollider ] } \
--set AUBIO_LIB "${aubio}/lib/libaubio.so"
--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 ] } \
--set AUBIO_LIB "${aubio}/lib/libaubio.so"
--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 ];
maintainers = with lib.maintainers; [ Phlogistique kamilchm c0deaddict sohalt ];
platforms = lib.platforms.linux;
};
}

0 comments on commit 9e5d59a

Please sign in to comment.