summary refs log tree commit diff
path: root/pkgs/test/make-binary-wrapper/cross.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/test/make-binary-wrapper/cross.nix')
-rw-r--r--pkgs/test/make-binary-wrapper/cross.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/pkgs/test/make-binary-wrapper/cross.nix b/pkgs/test/make-binary-wrapper/cross.nix
new file mode 100644
index 00000000000..36758086b92
--- /dev/null
+++ b/pkgs/test/make-binary-wrapper/cross.nix
@@ -0,0 +1,23 @@
+{ stdenv
+, runCommand
+, makeBinaryWrapper
+, binutils
+, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
+}:
+
+runCommand "make-binary-wrapper-test-cross" {
+  nativeBuildInputs = [
+    makeBinaryWrapper
+    binutils
+  ];
+  inherit expectedArch;
+} ''
+  touch prog
+  chmod +x prog
+  makeWrapper prog $out
+  read -r _ arch < <($READELF --file-header $out | grep Machine:)
+  if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
+    echo "expected $expectedArch, got $arch"
+    exit 1
+  fi
+''