commit ec6013cd52b73a80fcc67535b95d39e44a348e64 Author: phga Date: Tue Oct 11 02:01:51 2022 +0200 Init: Let's play piano on NixOS diff --git a/README.org b/README.org new file mode 100644 index 0000000..80f61a2 --- /dev/null +++ b/README.org @@ -0,0 +1,61 @@ +* Description + +A nix flake that installs Pianoteq7 on nixos. The license key and binary are still required and +have to be acquired manually from https://www.modartt.com/. + +* Usage + +Right now, I am really new to NixOS and Nix so this might be an awkward way of installing a package. +I might try to enhance this in the future and maybe even put it in the NUR. + +1. Download the ~pianoteq_linux_v754.7z~ file from https://www.modartt.com/ +2. Put ~pianoteq_linux_v754.7z~ into the nix store + +#+begin_src sh :results output scalar +nix-store --add-fixed sha256 ./pianoteq_linux_v754.7z +#+end_src + +3. In your main flake.nix file add the following line to your inputs + +#+begin_src nix :results output scalar +inputs = { + #... + pianoteq.url = "github:qhga/nix-pianoteq7"; + #... +}; +#+end_src + +4. Use the following in order to install the package + +#+begin_src nix :results output scalar + environment.systemPackages = [ + #... + pianoteq.packages.x86_64-linux.default + #... + ]; +#+end_src + +* Add a new Version + +1. Download the new release from https://www.modartt.com/ +2. Get the new sha256 hash in sri format + +#+begin_src sh :results output scalar +nix hash to-sri --type sha256 `sha256sum pianoteq_linux_$NEW_VERSION.7z` +#+end_src + +3. Change the version numbers in the flake.nix file and adjust the sha256 hash + +#+begin_src nix :results output scalar + src = requireFile { + name = "pianoteq_linux_$NEW_VERSION.7z"; + message = "Download the file from: https://www.modartt.com/download?file=pianoteq_linux_v754.7z and add it to the nix store manually: nix-store --add-fixed sha256 ./pianoteq_linux_v754.7z"; + sha256 = "$NEW_HASH"; + }; +#+end_src + +4. Put the new release 7z into the nix store + +#+begin_src sh :results output scalar +nix-store --add-fixed sha256 ./pianoteq_linux_$NEW_VERSION.7z +#+end_src diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a9fe259 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1665259268, + "narHash": "sha256-ONFhHBLv5nZKhwV/F2GOH16197PbvpyWhoO0AOyktkU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c5924154f000e6306030300592f4282949b2db6c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..886dc0d --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +# Author: phga +{ + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }@inputs: { + + packages.x86_64-linux.default = + + with import nixpkgs { system = "x86_64-linux"; }; + stdenv.mkDerivation rec { + pname = "pianoteq"; + version = "7.5.4"; + + icon = fetchurl { + name = "pianoteq_icon_128"; + url = "https://www.pianoteq.com/images/logo/pianoteq_icon_128.png"; + sha256 = "sha256-lO5kz2aIpJ108L9w2BHnRmq6wQP+6rF0lqifgor8xtM="; + }; + + # IMPORTANT: Use the following command to retrive the correct hash. + # Otherwise the file is not found in the nix store (Add it first ofc) + # nix hash to-sri --type sha256 `sha256sum pianoteq_linux_v754.7z` + src = requireFile { + name = "pianoteq_linux_v754.7z"; + message = "Download the file from: https://www.modartt.com/download?file=pianoteq_linux_v754.7z and add it to the nix store manually: nix-store --add-fixed sha256 ./pianoteq_linux_v754.7z"; + sha256 = "sha256-TA9CiuT21fQedlMUGz7bNNxYun5ArmRjvIxjOGqXDCs="; + }; + + # Alternative: Downloaded manually and place in this directory + # src = ./pianoteq_linux_v754.7z; + + desktopItems = [ + (makeDesktopItem { + name = "pianoteq7"; + desktopName = "Pianoteq 7"; + exec = "pianoteq7"; + icon = "pianoteq_icon_128"; + }) + ]; + + nativeBuildInputs = [ + p7zip + copyDesktopItems + ]; + + libPath = lib.makeLibraryPath [ + alsa-lib + freetype + xorg.libX11 + xorg.libXext + stdenv.cc.cc.lib + libjack2 + lv2 + ]; + + unpackCmd = "7z x ${src}"; + + # `runHook postInstall` is mandatory otherwise postInstall won't run + installPhase = '' + install -Dm 755 x86-64bit/Pianoteq\ 7 $out/bin/pianoteq7 + install -Dm 755 x86-64bit/Pianoteq\ 7.lv2/Pianoteq_7.so \ + $out/lib/lv2/Pianoteq\ 7.lv2/Pianoteq_7.so + patchelf --set-interpreter "$(< $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath $libPath "$out/bin/pianoteq7" + cd x86-64bit/Pianoteq\ 7.lv2/ + for i in *.ttl; do + install -D "$i" "$out/lib/lv2/Pianoteq 7.lv2/$i" + done + runHook postInstall + ''; + + # This also works instead of the following + # makeWrapper $out/bin/pianoteq7 $out/bin/pianoteq7_wrapped --prefix LD_LIBRARY_PATH : "$libPath" + fixupPhase = '':''; + + # Runs copyDesktopItems hook. + # Alternatively call copyDesktopItems manually in installPhase/fixupPhase + postInstall = '' + install -Dm 444 ${icon} $out/share/icons/hicolor/128x128/apps/pianoteq_icon_128.png + ''; + + meta = { + homepage = "https://www.modartt.com/"; + description = "Pianoteq is a virtual instrument which in contrast to other virtual instruments is physically modelled and thus can simulate the playability and complex behaviour of real acoustic instruments. Because there are no samples, the file size is just a tiny fraction of that required by other virtual instruments."; + platforms = lib.platforms.linux; + }; + }; + }; +} \ No newline at end of file