about summary refs log tree commit diff
path: root/pkgs/applications/emulators/box64
diff options
context:
space:
mode:
authorOPNA2608 <christoph.neidahl@gmail.com>2023-01-06 22:18:48 +0100
committerOPNA2608 <christoph.neidahl@gmail.com>2023-01-06 22:18:48 +0100
commit6da32655688c4fee4c8b7c09b220030738bbb885 (patch)
tree034354db657d3ecc8b5177f6a9c9084e0fb11454 /pkgs/applications/emulators/box64
parentfbcb61bd7eb19914cbd88789c3586a63ff46b72b (diff)
box64: More platforms, dynarec option, hello test, extra maintainer
Diffstat (limited to 'pkgs/applications/emulators/box64')
-rw-r--r--pkgs/applications/emulators/box64/default.nix57
1 files changed, 36 insertions, 21 deletions
diff --git a/pkgs/applications/emulators/box64/default.nix b/pkgs/applications/emulators/box64/default.nix
index 404ece153b1c0..12c13bb9ae87d 100644
--- a/pkgs/applications/emulators/box64/default.nix
+++ b/pkgs/applications/emulators/box64/default.nix
@@ -5,8 +5,15 @@
 , gitUpdater
 , cmake
 , python3
+, withDynarec ? stdenv.hostPlatform.isAarch64
+, runCommand
+, hello-x86_64
+, box64
 }:
 
+# Currently only supported on ARM
+assert withDynarec -> stdenv.hostPlatform.isAarch64;
+
 stdenv.mkDerivation rec {
   pname = "box64";
   version = "0.2.0";
@@ -33,49 +40,57 @@ stdenv.mkDerivation rec {
   ];
 
   cmakeFlags = [
-    "-DNOGIT=1"
-  ] ++ (
-    if stdenv.hostPlatform.system == "aarch64-linux" then
-      [
-        "-DARM_DYNAREC=ON"
-      ]
-    else [
-      "-DLD80BITS=1"
-      "-DNOALIGN=1"
-    ]
-  );
+    "-DNOGIT=ON"
+    "-DARM_DYNAREC=${if withDynarec then "ON" else "OFF"}"
+    "-DRV64=${if stdenv.hostPlatform.isRiscV64 then "ON" else "OFF"}"
+    "-DPPC64LE=${if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then "ON" else "OFF"}"
+  ] ++ lib.optionals stdenv.hostPlatform.isx86_64 [
+    "-DLD80BITS=ON"
+    "-DNOALIGN=ON"
+  ];
 
   installPhase = ''
     runHook preInstall
+
     install -Dm 0755 box64 "$out/bin/box64"
+
     runHook postInstall
   '';
 
   doCheck = true;
 
-  checkPhase = ''
-    runHook preCheck
-    ctest
-    runHook postCheck
-  '';
-
   doInstallCheck = true;
 
   installCheckPhase = ''
     runHook preInstallCheck
+
+    echo Checking if it works
     $out/bin/box64 -v
+
+    echo Checking if Dynarec option was respected
+    $out/bin/box64 -v | grep ${lib.optionalString (!withDynarec) "-v"} Dynarec
+
     runHook postInstallCheck
   '';
 
-  passthru.updateScript = gitUpdater {
-    rev-prefix = "v";
+  passthru = {
+    updateScript = gitUpdater {
+      rev-prefix = "v";
+    };
+    tests.hello = runCommand "box64-test-hello" {
+      nativeBuildInputs = [ box64 hello-x86_64 ];
+    } ''
+      # There is no actual "Hello, world!" with any of the logging enabled, and with all logging disabled it's hard to
+      # tell what problems the emulator has run into.
+      BOX64_NOBANNER=0 BOX64_LOG=1 box64 ${hello-x86_64}/bin/hello --version | tee $out
+    '';
   };
 
   meta = with lib; {
     homepage = "https://box86.org/";
     description = "Lets you run x86_64 Linux programs on non-x86_64 Linux systems";
     license = licenses.mit;
-    maintainers = with maintainers; [ gador ];
-    platforms = [ "x86_64-linux" "aarch64-linux" ];
+    maintainers = with maintainers; [ gador OPNA2608 ];
+    platforms = [ "x86_64-linux" "aarch64-linux" "riscv64-linux" "powerpc64le-linux" ];
   };
 }