nixpkgs/pkgs/top-level
sternenseemann 9d6cac3e53 mesonEmulatorHook: fix canExecute safety assertion
Currently the throw codepath will never be hit. Specifically it doesn't
guard against a misuse of the hook:

    pkgsCross.aarch64-multiplatform.mesonEmulatorHook # this should fail
    pkgsCross.aarch64-multiplatform.buildPackages.mesonEmulatorHook # this should (and does) succeed

The check sort of worked to guard against use in situations where the
hook wasn't misplaced between nativeBuildInputs and buildInputs, but
the build platform was actually able to execute binaries built for the
host platform.

This worked because nativeBuildInputs would first of all need to
evaluate pkgsHostTarget.mesonEmulatorHook in order to access the spliced
derivation it wants, pkgsBuildHost.mesonEmulatorHook. For this, you'd
need to pass the if expression, at which point buildPlatform and
targetPlatform would match the build and target platform of the
derivation that uses the hook. Consequently the check is “correct”,
since it is its build platform that needs not to be able execute stuff
built for its host platform.

The target platform is technically wrong here, but it works out
since (at least currently) in nixpkgs either build and host or host and
target platform are equal. When doing the check in pkgsHostTarget,
target and host platform are equal.

However, this is a kind of incomprehensible rube goldberg machine, let's
some mistakes slip through the cracks and relies on implementation
details of splicing.

To alleviate this, we do the following:

- We move the check _into_ the derivation. By doing the check when
  obtaining the file for the setup hook and not before calling
  `makeSetupHook`. This means that we can force `mesonEmulatorHook`
  even if forcing `mesonEmulatorHook.outPath` would throw. This ensures
  that splicing can work even if the some of the derivation variants
  would fail to evaluate.

- Since splicing works now, we can no longer have to do the check
  “globally” before splicing happens. This means we can use the setup
  hook derivation's own platforms. buildPlatform is irrelevant here,
  since this is only the platform on which the shell script is put
  together. hostPlatform matters, since it is were the setup hook is
  executed later (i.e. the using derivation's build platform). target
  platform is the platform the adjacent meson builds executables for,
  i.e. the platform we may need to emulate for.

To verify this change, I have evaluated all derivations using
mesonEmulatorHook in `pkgsCross.aarch64-multiplatform` before and after
this change. The hashes don't change.
2023-08-08 16:49:20 +02:00
..
pkg-config
agda-packages.nix agdaPackages._1lab: init at unstable-2023-03-07 2023-08-06 12:49:13 +02:00
aliases.nix planner: init at 0.14.91 2023-08-08 01:22:19 +00:00
all-packages.nix mesonEmulatorHook: fix canExecute safety assertion 2023-08-08 16:49:20 +02:00
beam-packages.nix
config.nix config.cudaSupport: init option 2023-07-20 17:57:31 +03:00
coq-packages.nix coqPackages.paco: 4.1.2 → 4.2.0 2023-08-03 04:30:34 +02:00
cubocore-packages.nix
cuda-packages.nix
darwin-packages.nix Revert "lib.customisation: uncurry makeScopeWithSplicing" 2023-07-28 23:04:09 +02:00
default.nix
dhall-packages.nix
dotnet-packages.nix
emacs-packages.nix emacs.pkgs.exwm: Prefer exwm from elpa devel 2023-06-22 18:48:49 +12:00
emscripten-packages.nix
gnuradio-packages.nix
haskell-packages.nix haskell.packages: use pkgs fix point for package set aliases 2023-07-01 11:56:56 +02:00
haxe-packages.nix
impure.nix
java-packages.nix javaPackages.jogl_2_4_0: add darwin support 2023-08-03 15:33:11 +02:00
kodi-packages.nix kodiPackages.libretro-fuse: init at 1.6.0.34 2023-06-27 19:48:49 +03:00
linux-kernels.nix Merge pull request #245677 from fsagbuya/linux-gpib 2023-08-08 14:52:14 +02:00
lua-packages.nix Merge master into staging-next 2023-07-24 00:02:26 +00:00
make-tarball.nix
metrics.nix
nim-packages.nix nimPackages.ws: init 0.5.0 2023-08-02 11:20:26 +01:00
nixpkgs-basic-release-checks.nix
ocaml-packages.nix ocamlPackages.{trace,trace-tef}: init at 0.2 2023-08-04 18:15:58 +02:00
octave-packages.nix
packages-config.nix
perl-packages.nix perlPackages.locallib: 2.000024 -> 2.000029 2023-08-08 03:45:42 +02:00
php-packages.nix phpExtensions.snuffleupagus: 0.7.0 -> 0.9.0 2023-07-11 22:20:45 +02:00
python2-packages.nix python2.pkgs.wcwidth: add missing python2 dependency 2023-08-03 07:49:32 -07:00
python-aliases.nix Merge branch 'master' into staging-next 2023-08-07 12:40:10 -07:00
python-packages.nix python3Packages.django-bootstrap5: init at 23.3 2023-08-08 15:25:52 +02:00
qt5-packages.nix mlt: build without qt5 2023-06-27 16:33:46 +03:00
qt6-packages.nix qt6Packages.qt6gtk2: init at 0.2 2023-07-27 15:39:28 -03:00
release-alternatives.nix
release-cross.nix
release-cuda.nix
release-haskell.nix
release-lib.nix
release-python.nix
release-r.nix
release-small.nix dhcp: remove 2023-07-28 16:35:40 +02:00
release.nix openssl_1_1: 1.1.1u -> 1.1.1v 2023-08-01 16:28:52 +02:00
ruby-packages.nix Merge pull request #240000 from aidalgol/jekyll-fixes 2023-08-07 00:50:37 +03:00
splice.nix treewide: fix some comments (#247365) 2023-08-05 23:01:26 +02:00
stage.nix pkgsStatic: add support for non-linux host platforms 2023-06-22 15:33:54 +10:00
unixtools.nix
wine-packages.nix