From d288ca992ac5184dbe2f3409a7831ccf835968d3 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Tue, 9 Aug 2022 22:32:11 +0200 Subject: [PATCH] fix the vital-synth derivation (use autoPatchelfHook) --- derivations/vital-synth/default.nix | 78 +++++++++++------------------ 1 file changed, 30 insertions(+), 48 deletions(-) diff --git a/derivations/vital-synth/default.nix b/derivations/vital-synth/default.nix index 6372dfb7..f7083918 100644 --- a/derivations/vital-synth/default.nix +++ b/derivations/vital-synth/default.nix @@ -1,4 +1,19 @@ -{ stdenv , fetchurl, alsa-lib, freetype, glib, glibc, libcurl-gnutls, libgl, libglvnd, libsecret }: +# Damn I hate this style +{ lib +, stdenv +, fetchurl +, dpkg +, autoPatchelfHook +, alsa-lib +, freetype +, gcc +, glib +, glibc +, curlWithGnuTls +, libGL +, libglvnd +, libsecret +}: # Adapted from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=vital-synth # Example https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/audio/bitwig-studio/bitwig-studio4.nix @@ -17,11 +32,15 @@ in stdenv.mkDerivation rec { sha512 = "829d29a0c41ac9f79ca6d069e2e4f404a501abdcdc487fbb4e1e8afd44bf870c6c41095587c98f810fb946d946179468f8d5f417e67785313152a1613cf4a832"; }; - # - wrapGAppsHook will add the applications share directory to XDG_DATA_DIRS - # It is also used to populate many environment variables related to icon themes etc. - # - makeWrapper allows to add environment variables and other stuff to the application, like a closure - # TODO: Is wrapGAppsHook needed? - nativeBuildInputs = [ dpkg makeWrapper wrapGAppsHook ]; + # autoPatchelfHook patches the binary to use the dynamic loader and "tells it" where all the libraries are that + # the program wants to dynamically load at runtime. + # This is necessary because NixOS doesn't have the linux typical static location where these libraries are placed, + # so the binary needs the correct paths to the nix store for each one. + # autoPatchelfHook propagates all the buildInputs so they are available at runtime. + nativeBuildInputs = [ + dpkg + autoPatchelfHook + ]; # We downloaded a .deb file, unpack it to root = [ usr/bin usr/lib usr/share ] unpackCmd = '' @@ -29,64 +48,27 @@ in stdenv.mkDerivation rec { dpkg-deb -x $curSrc root ''; + # This is already built dontBuild = true; - dontWrapGApps = true; # we only want $gappsWrapperArgs here # From AUR pkgbuild: # depends=('alsa-lib>=1.0.16' 'freetype2>=2.2.1' 'gcc-libs' 'gcc>=3.3.1' 'glib2>=2.12.0' 'glibc>=2.17' # 'libcurl-gnutls>=7.16.2' 'libgl' 'libglvnd' 'libsecret>=0.7') - # TODO: Verify every single dependency buildInputs = [ - alsa-lib freetype glib glibc libcurl-gnutls libgl libglvnd libsecret stdenv.cc.cc.lib + alsa-lib freetype gcc.cc.lib gcc.cc glib glibc curlWithGnuTls libGL libglvnd libsecret ]; + # TODO: Somehow/somehwere (in HomeManager?) we need to make a link to ~/.vst3 + # Copy the contents of the .deb package to the $out directory that nix creates for built derivations # Very simple as the vital .deb has a very basic format (only [ usr/bin usr/lib usr/share ]) installPhase = '' runHook preInstall - + mkdir -p $out cp -r usr/* $out/ chmod +x $out/bin/vital - runHook postInstall ''; - # This was also in the bitwig-studio example but I don't think it is needed as the .desktop - # file doesn't contain absolute paths to the executable. - # Also it probably requires that the .desktop file isn't already in $out/share/applications, - # but I copied it there already by copying all the contents from usr/ - # substitute usr/share/applications/vital.desktop \ - # $out/share/applications/vital.desktop \ - # --replace /usr/bin/vital $out/bin/vital - - # This is taken from the bitwig-studio example and I don't fully understand it... - # Basically the output path is searched for executables, these are then pached/linked with the - # needed libraries. These libraries are then provided through the LD_LIBRARY_PATH - postFixup = '' - # Find all executables that should be patched - find $out -type f -executable \ - -not -name '*.so.*' \ - -not -name '*.so' \ - - while IFS= read -r f ; do - # I don't exactly understand this, have to read up on patchelf - patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f - - wrapProgram $f \ - # I don't know what this does - "''${gappsWrapperArgs[@]}" \ - - # I don't know what binaries are needed for vital, probably not these - # --prefix PATH : "${lib.makeBinPath [ xdg-utils ffmpeg ]}" \ - - # We build the library path from our enabled buildInputs - --suffix LD_LIBRARY_PATH : "${lib.strings.makeLibraryPath buildInputs}" - done - ''; - # This is specific for bitwig-studio derivation - # find $out -type f -executable -name 'jspawnhelper' | \ - # while IFS= read -r f ; do - # patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f - # done meta = with lib; { description = "A wavetable synthesizer.";