summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers/meson/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/build-managers/meson/default.nix')
-rw-r--r--pkgs/development/tools/build-managers/meson/default.nix28
1 files changed, 27 insertions, 1 deletions
diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/default.nix
index aeddf457f48..62e16516392 100644
--- a/pkgs/development/tools/build-managers/meson/default.nix
+++ b/pkgs/development/tools/build-managers/meson/default.nix
@@ -1,4 +1,5 @@
 { lib
+, stdenv
 , fetchpatch
 , installShellFiles
 , ninja
@@ -63,7 +64,32 @@ python3.pkgs.buildPythonApplication rec {
     ./do-not-update-ldconfig-cache.patch
   ];
 
-  setupHook = ./setup-hook.sh;
+  cpuFamily = with stdenv.targetPlatform;
+    /**/ if isAarch32 then "arm"
+    else if isAarch64 then "aarch64"
+    else if isx86_32  then "x86"
+    else if isx86_64  then "x86_64"
+    else parsed.cpu.family + builtins.toString parsed.cpu.bits;
+
+  crossFile = if stdenv.hostPlatform == stdenv.targetPlatform then null else
+    builtins.toFile "cross-file.conf" ''
+      [properties]
+      needs_exe_wrapper = true
+
+      [host_machine]
+      system = '${stdenv.targetPlatform.parsed.kernel.name}'
+      cpu_family = '${cpuFamily}'
+      cpu = '${stdenv.targetPlatform.parsed.cpu.name}'
+      endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
+
+      [binaries]
+      llvm-config = 'llvm-config-native'
+    '';
+
+  setupHook = substituteAll {
+    src = ./setup-hook.sh;
+    crossFlags = lib.optionalString (crossFile != null) "--cross-file=${crossFile}";
+  };
 
   # Meson included tests since 0.45, however they fail in Nixpkgs because they
   # require a typical building environment (including C compiler and stuff).