2022-08-12 12:06:08 +00:00
|
|
|
{ stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
2022-08-12 12:06:08 +00:00
|
|
|
, wrapQtAppsHook
|
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
|
|
|
, cmake
|
|
|
|
, pkg-config
|
|
|
|
, catch2_3
|
|
|
|
, qtbase
|
|
|
|
, qtsvg
|
|
|
|
, qttools
|
|
|
|
, qwt
|
|
|
|
, qscintilla
|
|
|
|
, kissfftFloat
|
|
|
|
, crossguid
|
|
|
|
, reproc
|
|
|
|
, platform-folders
|
2020-04-24 23:36:52 +00:00
|
|
|
, ruby
|
2022-03-30 09:31:56 +00:00
|
|
|
, erlang
|
2022-08-12 12:06:08 +00:00
|
|
|
, elixir
|
|
|
|
, beamPackages
|
2022-03-30 09:31:56 +00:00
|
|
|
, alsa-lib
|
|
|
|
, rtmidi
|
2020-04-24 23:36:52 +00:00
|
|
|
, boost
|
2022-08-12 12:06:08 +00:00
|
|
|
, aubio
|
2021-04-05 15:23:46 +00:00
|
|
|
, jack2
|
2022-07-14 12:49:19 +00:00
|
|
|
, supercollider-with-sc3-plugins
|
2022-08-12 12:06:08 +00:00
|
|
|
, parallel
|
|
|
|
|
|
|
|
, withTauWidget ? false
|
|
|
|
, qtwebengine
|
|
|
|
|
|
|
|
, withImGui ? false
|
|
|
|
, gl3w
|
|
|
|
, SDL2
|
|
|
|
, fmt
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "sonic-pi";
|
2022-10-21 18:38:19 +00:00
|
|
|
version = "4.3.0";
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
2022-03-30 09:31:56 +00:00
|
|
|
owner = "sonic-pi-net";
|
2022-08-12 12:06:08 +00:00
|
|
|
repo = pname;
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
2022-10-21 18:38:19 +00:00
|
|
|
hash = "sha256-R+nmjIIDLoGOoCkDvJqejE1DaweHSAV8M2RvdwN5qAQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
mixFodDeps = beamPackages.fetchMixDeps {
|
|
|
|
inherit version;
|
|
|
|
pname = "mix-deps-${pname}";
|
|
|
|
mixEnv = "test";
|
|
|
|
src = "${src}/app/server/beam/tau";
|
|
|
|
sha256 = "sha256-MvwUyVTS23vQKLpGxz46tEVCs/OyYk5dDaBlv+kYg1M=";
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
strictDeps = true;
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
wrapQtAppsHook
|
|
|
|
copyDesktopItems
|
|
|
|
cmake
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2022-08-12 12:06:08 +00:00
|
|
|
erlang
|
|
|
|
elixir
|
|
|
|
beamPackages.hex
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2020-04-24 23:36:52 +00:00
|
|
|
qtbase
|
2022-08-12 12:06:08 +00:00
|
|
|
qtsvg
|
|
|
|
qttools
|
2020-04-24 23:36:52 +00:00
|
|
|
qwt
|
2022-08-12 12:06:08 +00:00
|
|
|
qscintilla
|
|
|
|
kissfftFloat
|
|
|
|
catch2_3
|
|
|
|
crossguid
|
|
|
|
reproc
|
|
|
|
platform-folders
|
2020-04-24 23:36:52 +00:00
|
|
|
ruby
|
2022-03-30 09:31:56 +00:00
|
|
|
alsa-lib
|
|
|
|
rtmidi
|
2022-08-12 12:06:08 +00:00
|
|
|
boost
|
|
|
|
aubio
|
|
|
|
] ++ lib.optionals withTauWidget [
|
|
|
|
qtwebengine
|
|
|
|
] ++ lib.optionals withImGui [
|
|
|
|
gl3w
|
|
|
|
SDL2
|
|
|
|
fmt
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
checkInputs = [
|
|
|
|
parallel
|
|
|
|
ruby
|
|
|
|
supercollider-with-sc3-plugins
|
|
|
|
jack2
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DUSE_SYSTEM_LIBS=ON"
|
|
|
|
"-DBUILD_IMGUI_INTERFACE=${if withImGui then "ON" else "OFF"}"
|
|
|
|
"-DWITH_QT_GUI_WEBENGINE=${if withTauWidget then "ON" else "OFF"}"
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# Fix shebangs on files in app and bin scripts
|
|
|
|
patchShebangs app bin
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
preConfigure = ''
|
|
|
|
# Set build environment
|
|
|
|
export SONIC_PI_HOME="$TMPDIR/spi"
|
|
|
|
|
|
|
|
export HEX_HOME="$TEMPDIR/hex"
|
|
|
|
export HEX_OFFLINE=1
|
|
|
|
export MIX_REBAR3='${beamPackages.rebar3}/bin/rebar3'
|
|
|
|
export REBAR_GLOBAL_CONFIG_DIR="$TEMPDIR/rebar3"
|
|
|
|
export REBAR_CACHE_DIR="$TEMPDIR/rebar3.cache"
|
|
|
|
export MIX_HOME="$TEMPDIR/mix"
|
|
|
|
export MIX_DEPS_PATH="$TEMPDIR/deps"
|
|
|
|
export MIX_ENV=prod
|
|
|
|
|
|
|
|
# Copy Mix dependency sources
|
|
|
|
echo 'Copying ${mixFodDeps} to Mix deps'
|
|
|
|
cp --no-preserve=mode -R '${mixFodDeps}' "$MIX_DEPS_PATH"
|
|
|
|
|
|
|
|
# Change to project base directory
|
|
|
|
cd app
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Prebuild Ruby vendored dependencies and Qt docs
|
|
|
|
./linux-prebuild.sh -o
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Append CMake flag depending on the value of $out
|
|
|
|
cmakeFlags+=" -DAPP_INSTALL_ROOT=$out/app"
|
2022-03-30 09:31:56 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
postBuild = ''
|
|
|
|
# Build BEAM server
|
|
|
|
../linux-post-tau-prod-release.sh -o
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# BEAM tests
|
|
|
|
pushd ../server/beam/tau
|
|
|
|
MIX_ENV=test TAU_ENV=test mix test
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Ruby tests
|
|
|
|
pushd ../server/ruby
|
|
|
|
rake test
|
|
|
|
popd
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# API tests
|
|
|
|
pushd api-tests
|
|
|
|
# run JACK parallel to tests and quit both when one exits
|
|
|
|
SONIC_PI_ENV=test parallel --no-notice -j2 --halt now,done=1 ::: 'jackd -rd dummy' 'ctest --verbose'
|
2020-04-24 23:36:52 +00:00
|
|
|
popd
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
runHook postCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Run Linux release script
|
|
|
|
../linux-release.sh
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Copy dist directory to output
|
|
|
|
mkdir $out
|
|
|
|
cp -r linux_dist/* $out/
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Copy icon
|
|
|
|
install -Dm644 ../gui/qt/images/icon-smaller.png $out/share/icons/hicolor/256x256/apps/sonic-pi.png
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
# $out/bin/sonic-pi is a shell script, and wrapQtAppsHook doesn't wrap them.
|
|
|
|
dontWrapQtApps = true;
|
|
|
|
preFixup = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
# Wrap Qt GUI (distributed binary)
|
|
|
|
wrapQtApp $out/bin/sonic-pi \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ ruby supercollider-with-sc3-plugins jack2 ]}
|
|
|
|
|
|
|
|
# If ImGui was built
|
|
|
|
if [ -e $out/app/build/gui/imgui/sonic-pi-imgui ]; then
|
|
|
|
# Wrap ImGui into bin
|
|
|
|
makeWrapper $out/app/build/gui/imgui/sonic-pi-imgui $out/bin/sonic-pi-imgui \
|
|
|
|
--inherit-argv0 \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ ruby supercollider-with-sc3-plugins jack2 ]}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove runtime Erlang references
|
|
|
|
for file in $(grep -FrIl '${erlang}/lib/erlang' $out/app/server/beam/tau); do
|
|
|
|
substituteInPlace "$file" --replace '${erlang}/lib/erlang' $out/app/server/beam/tau/_build/prod/rel/tau
|
|
|
|
done
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
stripDebugList = [ "app" "bin" ];
|
|
|
|
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "sonic-pi";
|
|
|
|
exec = "sonic-pi";
|
|
|
|
icon = "sonic-pi";
|
|
|
|
desktopName = "Sonic Pi";
|
|
|
|
comment = meta.description;
|
|
|
|
categories = [ "Audio" "AudioVideo" "Education" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://sonic-pi.net/";
|
|
|
|
description = "Free live coding synth for everyone originally designed to support computing and music lessons within schools";
|
2022-08-12 12:06:08 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ Phlogistique kamilchm c0deaddict sohalt lilyinstarlight ];
|
|
|
|
platforms = platforms.linux;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|