nixpkgs-suyu/pkgs/applications/audio/sonic-pi/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

140 lines
3.1 KiB
Nix
Raw Normal View History

2019-09-08 14:20:34 +02:00
{ mkDerivation
, lib
, qtbase
2015-11-15 21:16:00 +01:00
, fetchFromGitHub
2017-10-05 16:44:59 +02:00
, fftwSinglePrec
2015-11-15 21:16:00 +01:00
, ruby
2022-03-13 01:33:15 +01:00
, erlang
2017-10-05 16:44:59 +02:00
, aubio
2022-03-13 01:33:15 +01:00
, alsa-lib
, rtmidi
, libsndfile
2015-11-15 21:16:00 +01:00
, cmake
, pkg-config
2017-10-05 16:44:59 +02:00
, boost
2015-11-15 21:16:00 +01:00
, bash
2021-03-14 17:03:47 +01:00
, jack2
2019-09-08 14:20:34 +02:00
, supercollider
, qwt
2015-11-15 21:16:00 +01:00
}:
2017-10-05 16:44:59 +02:00
let
2019-09-08 14:20:34 +02:00
supercollider_single_prec = supercollider.override { fftw = fftwSinglePrec; };
pname = "sonic-pi";
2022-03-13 01:33:15 +01:00
version = "3.3.1";
2015-11-15 21:16:00 +01:00
src = fetchFromGitHub {
2022-03-13 01:33:15 +01:00
owner = "sonic-pi-net";
2015-11-15 21:16:00 +01:00
repo = "sonic-pi";
rev = "v${version}";
2022-03-13 01:33:15 +01:00
sha256 = "sha256-AE7iuSNnW1SAtBMplReGzXKcqD4GG23i10MIAWnlcPo=";
2015-11-15 21:16:00 +01:00
};
2022-03-13 01:33:15 +01:00
# 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;
nativeBuildInputs = [ cmake ];
2015-11-15 21:16:00 +01:00
buildInputs = [
bash
pkg-config
2019-09-08 14:20:34 +02:00
qtbase
qwt
ruby
2017-10-05 16:44:59 +02:00
aubio
2019-09-08 14:20:34 +02:00
supercollider_single_prec
2017-10-05 16:44:59 +02:00
boost
2022-03-13 01:33:15 +01:00
erlang
alsa-lib
rtmidi
2015-11-15 21:16:00 +01:00
];
dontUseCmakeConfigure = true;
2022-03-13 01:33:15 +01:00
prePatch = ''
sed -i '/aubio/d' app/external/linux_build_externals.sh
sed -i '/aubio/d' app/linux-prebuild.sh
patchShebangs app
'';
2022-03-13 01:33:15 +01:00
configurePhase = ''
runHook preConfigure
2017-10-05 16:44:59 +02:00
2022-03-13 01:33:15 +01:00
./app/linux-prebuild.sh
./app/linux-config.sh
2015-11-15 21:16:00 +01:00
2022-03-13 01:33:15 +01:00
runHook postConfigure
'';
2017-10-05 16:44:59 +02:00
2022-03-13 01:33:15 +01:00
buildPhase = ''
runHook preBuild
2017-10-05 16:44:59 +02:00
2022-03-13 01:33:15 +01:00
pushd app/build
cmake --build . --config Release
2015-11-15 21:16:00 +01:00
popd
2022-03-13 01:33:15 +01:00
runHook postBuild
2015-11-15 21:16:00 +01:00
'';
installPhase = ''
2017-10-05 16:44:59 +02:00
runHook preInstall
2020-03-08 12:16:05 +01:00
mkdir $out
cp -r {bin,etc} $out/
# Copy server whole.
mkdir -p $out/app
cp -r app/server $out/app/
2022-03-13 01:33:15 +01:00
# We didn't build this during linux-prebuild.sh so copy from the separate derivation
cp ${aubioonset}/aubioonset $out/app/server/native/
2020-03-08 12:16:05 +01:00
# Copy only necessary files for the gui app.
2022-03-13 01:33:15 +01:00
mkdir -p $out/app/gui/qt
2020-03-08 12:16:05 +01:00
cp -r app/gui/qt/{book,fonts,help,html,images,image_source,info,lang,theme} $out/app/gui/qt/
2022-03-13 01:33:15 +01:00
mkdir -p $out/app/build/gui/qt
cp app/build/gui/qt/sonic-pi $out/app/build/gui/qt/sonic-pi
2020-03-08 12:16:05 +01:00
2019-09-08 14:20:34 +02:00
runHook postInstall
'';
# $out/bin/sonic-pi is a shell script, and wrapQtAppsHook doesn't wrap them.
dontWrapQtApps = true;
preFixup = ''
wrapQtApp "$out/bin/sonic-pi" \
2022-03-13 01:33:15 +01:00
--prefix PATH : ${lib.makeBinPath [ bash jack2 ruby supercollider erlang] }
makeWrapper \
$out/app/server/ruby/bin/sonic-pi-server.rb \
$out/bin/sonic-pi-server \
2022-03-13 01:33:15 +01:00
--prefix PATH : ${lib.makeBinPath [ bash jack2 ruby supercollider erlang ] }
2015-11-15 21:16:00 +01:00
'';
2017-10-05 16:44:59 +02:00
meta = {
2019-09-21 10:22:08 +02:00
homepage = "https://sonic-pi.net/";
2017-10-05 16:44:59 +02:00
description = "Free live coding synth for everyone originally designed to support computing and music lessons within schools";
2019-09-08 14:20:34 +02:00
license = lib.licenses.mit;
2022-03-13 01:33:15 +01:00
maintainers = with lib.maintainers; [ Phlogistique kamilchm c0deaddict sohalt ];
2019-09-08 14:20:34 +02:00
platforms = lib.platforms.linux;
2017-10-05 16:44:59 +02:00
};
2015-11-15 21:16:00 +01:00
}