python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / audio / yabridge / default.nix
blob6287c532382f87aef29d3585276f705f09deb074
1 { lib
2 , multiStdenv
3 , fetchFromGitHub
4 , substituteAll
5 , pkgsi686Linux
6 , libnotify
7 , meson
8 , ninja
9 , pkg-config
10 , wine
11 , libxcb
12 , nix-update-script
15 let
16   # Derived from subprojects/asio.wrap
17   asio = fetchFromGitHub {
18     owner = "chriskohlhoff";
19     repo = "asio";
20     rev = "asio-1-22-1";
21     sha256 = "sha256-UDLhx2yI6Txg0wP5H4oNIhgKIB2eMxUGCyT2x/7GgVg=";
22   };
24   # Derived from subprojects/bitsery.wrap
25   bitsery = fetchFromGitHub {
26     owner = "fraillt";
27     repo = "bitsery";
28     rev = "v5.2.2";
29     sha256 = "sha256-VwzVtxt+E/SVcxqIJw8BKPO2q7bu/hkhY+nB7FHrZpY=";
30   };
32   # Derived from subprojects/function2.wrap
33   function2 = fetchFromGitHub {
34     owner = "Naios";
35     repo = "function2";
36     rev = "4.2.0";
37     sha256 = "sha256-wrt+fCcM6YD4ZRZYvqqB+fNakCNmltdPZKlNkPLtgMs=";
38   };
40   # Derived from subprojects/ghc_filesystem.wrap
41   ghc_filesystem = fetchFromGitHub {
42     owner = "gulrak";
43     repo = "filesystem";
44     rev = "v1.5.12";
45     sha256 = "sha256-j4RE5Ach7C7Kef4+H9AHSXa2L8OVyJljDwBduKcC4eE=";
46   };
48   # Derived from subprojects/tomlplusplus.wrap
49   tomlplusplus = fetchFromGitHub {
50     owner = "marzer";
51     repo = "tomlplusplus";
52     rev = "v3.0.1";
53     sha256 = "sha256-l8ckbCqjz3GUfwStcl3H2C+un5dZfT2uLtayvdu93D4=";
54   };
56   # Derived from vst3.wrap
57   vst3 = fetchFromGitHub {
58     owner = "robbert-vdh";
59     repo = "vst3sdk";
60     rev = "v3.7.5_build_44-patched";
61     fetchSubmodules = true;
62     sha256 = "sha256-6cuEUa+BXa6MnAYIBq873n0NRLadcPfMX+kpf4ysE6M=";
63   };
64 in multiStdenv.mkDerivation rec {
65   pname = "yabridge";
66   version = "4.0.2";
68   # NOTE: Also update yabridgectl's cargoHash when this is updated
69   src = fetchFromGitHub {
70     owner = "robbert-vdh";
71     repo = pname;
72     rev = version;
73     sha256 = "sha256-rce6gxnB+RpG84Xakw0h4vZ8lyEQ41swWQGuwpomV2I=";
74   };
76   # Unpack subproject sources
77   postUnpack = ''(
78     cd "$sourceRoot/subprojects"
79     cp -R --no-preserve=mode,ownership ${asio} asio
80     cp -R --no-preserve=mode,ownership ${bitsery} bitsery
81     cp -R --no-preserve=mode,ownership ${function2} function2
82     cp -R --no-preserve=mode,ownership ${ghc_filesystem} ghc_filesystem
83     cp -R --no-preserve=mode,ownership ${tomlplusplus} tomlplusplus
84     cp -R --no-preserve=mode,ownership ${vst3} vst3
85   )'';
87   patches = [
88     # Hard code bitbridge & runtime dependencies
89     (substituteAll {
90       src = ./hardcode-dependencies.patch;
91       libxcb32 = pkgsi686Linux.xorg.libxcb;
92       inherit libnotify wine;
93     })
95     # Patch the chainloader to search for libyabridge through NIX_PROFILES
96     ./libyabridge-from-nix-profiles.patch
97   ];
99   postPatch = ''
100     patchShebangs .
101     (
102       cd subprojects
103       cp packagefiles/asio/* asio
104       cp packagefiles/bitsery/* bitsery
105       cp packagefiles/function2/* function2
106       cp packagefiles/ghc_filesystem/* ghc_filesystem
107     )
108   '';
110   nativeBuildInputs = [
111     meson
112     ninja
113     pkg-config
114     wine
115   ];
117   buildInputs = [
118     libxcb
119   ];
121   mesonFlags = [
122     "--cross-file" "cross-wine.conf"
123     "-Dbitbridge=true"
125     # Requires CMake and is unnecessary
126     "-Dtomlplusplus:generate_cmake_config=false"
127   ];
129   installPhase = ''
130     runHook preInstall
131     mkdir -p "$out/bin" "$out/lib"
132     cp yabridge-host{,-32}.exe{,.so} "$out/bin"
133     cp libyabridge{,-chainloader}-{vst2,vst3}.so "$out/lib"
134     runHook postInstall
135   '';
137   # Hard code wine path in wrapper scripts generated by winegcc
138   postFixup = ''
139     for exe in "$out"/bin/*.exe; do
140       substituteInPlace "$exe" \
141         --replace 'WINELOADER="wine"' 'WINELOADER="${wine}/bin/wine"'
142     done
143   '';
145   passthru.updateScript = nix-update-script {
146     attrPath = pname;
147   };
149   meta = with lib; {
150     description = "A modern and transparent way to use Windows VST2 and VST3 plugins on Linux";
151     homepage = src.meta.homepage;
152     license = licenses.gpl3Plus;
153     maintainers = with maintainers; [ kira-bruneau ];
154     platforms = [ "x86_64-linux" ];
155   };