mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-16 02:33:25 +00:00
9d6cac3e53
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. |
||
---|---|---|
.. | ||
pkg-config | ||
agda-packages.nix | ||
aliases.nix | ||
all-packages.nix | ||
beam-packages.nix | ||
config.nix | ||
coq-packages.nix | ||
cubocore-packages.nix | ||
cuda-packages.nix | ||
darwin-packages.nix | ||
default.nix | ||
dhall-packages.nix | ||
dotnet-packages.nix | ||
emacs-packages.nix | ||
emscripten-packages.nix | ||
gnuradio-packages.nix | ||
haskell-packages.nix | ||
haxe-packages.nix | ||
impure.nix | ||
java-packages.nix | ||
kodi-packages.nix | ||
linux-kernels.nix | ||
lua-packages.nix | ||
make-tarball.nix | ||
metrics.nix | ||
nim-packages.nix | ||
nixpkgs-basic-release-checks.nix | ||
ocaml-packages.nix | ||
octave-packages.nix | ||
packages-config.nix | ||
perl-packages.nix | ||
php-packages.nix | ||
python2-packages.nix | ||
python-aliases.nix | ||
python-packages.nix | ||
qt5-packages.nix | ||
qt6-packages.nix | ||
release-alternatives.nix | ||
release-cross.nix | ||
release-cuda.nix | ||
release-haskell.nix | ||
release-lib.nix | ||
release-python.nix | ||
release-r.nix | ||
release-small.nix | ||
release.nix | ||
ruby-packages.nix | ||
splice.nix | ||
stage.nix | ||
unixtools.nix | ||
wine-packages.nix |