7 , withDynarec ? (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isRiscV64)
12 # Currently only supported on ARM & RISC-V
13 assert withDynarec -> (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isRiscV64);
15 stdenv.mkDerivation (finalAttrs: {
19 src = fetchFromGitHub {
22 rev = "v${finalAttrs.version}";
23 hash = "sha256-eKYnBuaEWRb6kDGFvuG+xM70LbUAcJ6Zcr6hPHqi9Do=";
35 "-DARM64=${lib.boolToString stdenv.hostPlatform.isAarch64}"
36 "-DRV64=${lib.boolToString stdenv.hostPlatform.isRiscV64}"
37 "-DPPC64LE=${lib.boolToString (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian)}"
38 "-DLARCH64=${lib.boolToString stdenv.hostPlatform.isLoongArch64}"
39 ] ++ lib.optionals stdenv.hostPlatform.isx86_64 [
40 # x86_64 has no arch-specific mega-option, manually enable the options that apply to it
45 "-DARM_DYNAREC=${lib.boolToString (withDynarec && stdenv.hostPlatform.isAarch64)}"
46 "-DRV64_DYNAREC=${lib.boolToString (withDynarec && stdenv.hostPlatform.isRiscV64)}"
52 install -Dm 0755 box64 "$out/bin/box64"
57 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
59 doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
61 installCheckPhase = ''
62 runHook preInstallCheck
64 echo Checking if it works
67 echo Checking if Dynarec option was respected
68 $out/bin/box64 -v | grep ${lib.optionalString (!withDynarec) "-v"} Dynarec
70 runHook postInstallCheck
74 updateScript = gitUpdater {
77 tests.hello = runCommand "box64-test-hello" {
78 nativeBuildInputs = [ finalAttrs.finalPackage ];
80 # There is no actual "Hello, world!" with any of the logging enabled, and with all logging disabled it's hard to
81 # tell what problems the emulator has run into.
82 BOX64_NOBANNER=0 BOX64_LOG=1 box64 ${hello-x86_64}/bin/hello --version | tee $out
87 homepage = "https://box86.org/";
88 description = "Lets you run x86_64 Linux programs on non-x86_64 Linux systems";
89 license = licenses.mit;
90 maintainers = with maintainers; [ gador OPNA2608 ];
91 mainProgram = "box64";
92 platforms = [ "x86_64-linux" "aarch64-linux" "riscv64-linux" "powerpc64le-linux" "loongarch64-linux" "mips64el-linux" ];