diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5c00f7ce8501..fe6d1e576c65 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5821,18 +5821,23 @@ with pkgs; # example of an error which this fixes # [Errno 8] Exec format error: './gdk3-scan' mesonEmulatorHook = - if (!stdenv.buildPlatform.canExecute stdenv.targetPlatform) then - makeSetupHook - { - name = "mesonEmulatorHook"; - substitutions = { - crossFile = writeText "cross-file.conf" '' + makeSetupHook + { + name = "mesonEmulatorHook"; + substitutions = { + crossFile = writeText "cross-file.conf" '' [binaries] - exe_wrapper = ${lib.escapeShellArg (stdenv.targetPlatform.emulator buildPackages)} + exe_wrapper = ${lib.escapeShellArg (stdenv.targetPlatform.emulator pkgs)} ''; - }; - } ../development/tools/build-managers/meson/emulator-hook.sh - else throw "mesonEmulatorHook has to be in a conditional to check if the target binaries can be executed i.e. (!stdenv.buildPlatform.canExecute stdenv.hostPlatform)"; + }; + } + # The throw is moved into the `makeSetupHook` derivation, so that its + # outer level, but not its outPath can still be evaluated if the condition + # doesn't hold. This ensures that splicing still can work correctly. + (if (!stdenv.hostPlatform.canExecute stdenv.targetPlatform) then + ../development/tools/build-managers/meson/emulator-hook.sh + else + throw "mesonEmulatorHook may only be added to nativeBuildInputs when the target binaries can't be executed; however you are attempting to use it in a situation where ${stdenv.hostPlatform.config} can execute ${stdenv.targetPlatform.config}. Consider only adding mesonEmulatorHook according to a conditional based canExecute in your package expression."); meson-tools = callPackage ../misc/meson-tools { };