20 versionForFile = v: builtins.replaceStrings [ "." ] [ "" ] v;
28 , archdir ? if (stdenv.hostPlatform.system == "aarch64-linux") then "arm-64bit" else "x86-64bit"
31 stdenv.mkDerivation rec {
34 pname = "pianoteq-${name}";
37 ${p7zip}/bin/7z x $src
48 (lib.getLib stdenv.cc.cc)
49 xorg.libX11 # libX11.so.6
50 xorg.libXext # libXext.so.6
51 alsa-lib # libasound.so.2
52 freetype # libfreetype.so.6
58 exec = ''"${mainProgram}"'';
59 desktopName = mainProgram;
61 comment = meta.description;
62 categories = [ "AudioVideo" "Audio" "Recorder" ];
63 startupNotify = false;
64 inherit startupWMClass;
71 mv -t $out/bin Pianoteq*/${archdir}/*
72 for f in $out/bin/Pianoteq*; do
73 if [ -x "$f" ] && [ -f "$f" ]; then
74 wrapProgram "$f" --prefix LD_LIBRARY_PATH : ${
75 lib.makeLibraryPath (buildInputs ++ [
85 install -Dm644 ${./pianoteq.svg} $out/share/icons/hicolor/scalable/apps/pianoteq.svg
86 for size in 16 22 32 48 64 128 256; do
87 dir=$out/share/icons/hicolor/"$size"x"$size"/apps
93 --output $dir/pianoteq.png \
100 homepage = "https://www.modartt.com/pianoteq";
101 description = "Software synthesizer that features real-time MIDI-control of digital physically modeled pianos and related instruments";
102 license = licenses.unfree;
104 platforms = [ "x86_64-linux" "aarch64-linux" ];
105 maintainers = with maintainers; [ mausch ners ];
106 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
110 fetchWithCurlScript = { name, hash, script, impureEnvVars ? [ ] }:
111 stdenv.mkDerivation {
113 builder = writeShellScript "builder.sh" ''
116 curlVersion=$(${curl}/bin/curl -V | head -1 | cut -d' ' -f2)
118 # Curl flags to handle redirects, not use EPSV, handle cookies for
119 # servers to need them during redirects, and work on SSL without a
120 # certificate (this isn't a security problem because we check the
121 # cryptographic hash of the output anyway).
130 --user-agent "curl/$curlVersion Nixpkgs/${lib.trivial.release}"
137 nativeBuildInputs = [ curl ];
138 outputHashAlgo = "sha256";
141 impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ impureEnvVars ++ [
142 # This variable allows the user to pass additional options to curl
147 fetchPianoteqTrial = { name, hash }:
148 fetchWithCurlScript {
152 "''${curl[@]}" --silent --request GET \
154 --header "accept: */*" \
155 'https://www.modartt.com/try?file=${name}'
158 signature="$(echo "$html" | ${htmlq}/bin/htmlq '#download-form' --attribute action | cut -f2 -d'&' | cut -f2 -d=)"
161 "''${curl[@]}" --silent --request POST \
163 --header "modartt-json: request" \
164 --header "origin: https://www.modartt.com" \
165 --header "content-type: application/json; charset=UTF-8" \
166 --header "accept: application/json, text/javascript, */*" \
167 --data-raw '{"file": "${name}", "get": "url", "signature": "'"$signature"'"}' \
168 https://www.modartt.com/api/0/download
171 url=$(echo $json | ${jq}/bin/jq -r .url)
172 if [ "$url" == "null" ]; then
173 echo "Could not get download URL, open an issue on https://github.com/NixOS/nixpkgs"
176 "''${curl[@]}" --progress-bar --cookie cookies -o $out "$url"
180 fetchPianoteqWithLogin = { name, hash }:
181 fetchWithCurlScript {
184 impureEnvVars = [ "NIX_MODARTT_USERNAME" "NIX_MODARTT_PASSWORD" ];
187 if [ -z "''${NIX_MODARTT_USERNAME}" -o -z "''${NIX_MODARTT_PASSWORD}" ]; then
188 echo "Error: Downloading a personal Pianoteq instance requires the nix building process (nix-daemon in multi user mode) to have the NIX_MODARTT_USERNAME and NIX_MODARTT_PASSWORD env vars set." >&2
192 "''${curl[@]}" -s -o /dev/null "https://www.modartt.com/user_area"
194 ${jq}/bin/jq -n "{connect: 1, login: \"''${NIX_MODARTT_USERNAME}\", password: \"''${NIX_MODARTT_PASSWORD}\"}" > login.json
196 "''${curl[@]}" --silent --request POST \
198 --referer "https://www.modartt.com/user_area" \
199 --header "modartt-json: request" \
200 --header "origin: https://www.modartt.com" \
201 --header "content-type: application/json; charset=UTF-8" \
202 --header "accept: application/json, text/javascript, */*" \
204 https://www.modartt.com/api/0/session
207 "''${curl[@]}" --silent --request POST \
209 --header "modartt-json: request" \
210 --header "origin: https://www.modartt.com" \
211 --header "content-type: application/json; charset=UTF-8" \
212 --header "accept: application/json, text/javascript, */*" \
213 --data-raw '{"file": "${name}", "get": "url"}' \
214 https://www.modartt.com/api/0/download
217 url=$(echo $json | ${jq}/bin/jq -r .url)
218 "''${curl[@]}" --progress-bar --cookie cookies -o $out "$url"
224 # TODO currently can't install more than one because `lame` clashes
225 stage-trial = mkPianoteq rec {
226 name = "stage-trial";
227 mainProgram = "Pianoteq 8 STAGE";
228 startupWMClass = "Pianoteq STAGE Trial";
230 src = fetchPianoteqTrial {
231 name = "pianoteq_stage_linux_trial_v${versionForFile version}.7z";
232 hash = "sha256-66xbcqNrnVJ+C9FQ8Bg8A7nj/bFrjt6jKheusrXVWvI=";
235 standard-trial = mkPianoteq rec {
236 name = "standard-trial";
237 mainProgram = "Pianoteq 8";
238 startupWMClass = "Pianoteq Trial";
240 src = fetchPianoteqTrial {
241 name = "pianoteq_linux_trial_v${versionForFile version}.7z";
242 hash = "sha256-IFFQMn8EFo5X8sUZV2/vtQOA83NHEFrUsU++CvYbN1c=";
245 stage-6 = mkPianoteq rec {
247 mainProgram = "Pianoteq 6 STAGE";
248 startupWMClass = "Pianoteq STAGE";
250 archdir = if (stdenv.hostPlatform.system == "aarch64-linux") then throw "Pianoteq stage-6 is not supported on aarch64-linux" else "amd64";
251 src = fetchPianoteqWithLogin {
252 name = "pianoteq_stage_linux_v${versionForFile version}.7z";
253 hash = "0jy0hkdynhwv0zhrqkby0hdphgmcc09wxmy74rhg9afm1pzl91jy";
256 stage-7 = mkPianoteq rec {
258 mainProgram = "Pianoteq 7 STAGE";
259 startupWMClass = "Pianoteq STAGE";
261 src = fetchPianoteqWithLogin {
262 name = "pianoteq_stage_linux_v${versionForFile version}.7z";
263 hash = "05w7sv9v38r6ljz9xai816w5z2qqwx88hcfjm241fvgbs54125hx";
266 standard-8 = mkPianoteq rec {
268 mainProgram = "Pianoteq 8";
269 startupWMClass = "Pianoteq";
271 src = fetchPianoteqWithLogin {
272 name = "pianoteq_linux_v${versionForFile version}.7z";
273 hash = "sha256-ME0urUc1jwUKpg+5BdawYo9WhvMsrztYTVOrJTVxtkY=";
276 # TODO other paid binaries, I don't own that so I don't know their hash.