Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 102 lines 2.7 kB view raw
1{ 2 buildPackages, 3 lib, 4 stdenv, 5 fetchFromGitHub, 6 cmake, 7 python3, 8 withDynarec ? stdenv.hostPlatform.isAarch32, 9 runCommand, 10 hello-x86_32, 11}: 12 13# Currently only supported on specific archs 14assert withDynarec -> stdenv.hostPlatform.isAarch32; 15 16stdenv.mkDerivation (finalAttrs: { 17 pname = "box86"; 18 version = "0.3.8"; 19 20 src = fetchFromGitHub { 21 owner = "ptitSeb"; 22 repo = "box86"; 23 rev = "v${finalAttrs.version}"; 24 hash = "sha256-/xeyb4NK5ZzPevlAjjSnc6JAmsmqnx3slaMfPLL9dYI="; 25 }; 26 27 nativeBuildInputs = [ 28 cmake 29 python3 30 ]; 31 32 cmakeFlags = [ 33 (lib.cmakeBool "NOGIT" true) 34 35 # Arch mega-option 36 (lib.cmakeBool "POWERPCLE" (stdenv.hostPlatform.isPower && stdenv.hostPlatform.isLittleEndian)) 37 ] 38 ++ lib.optionals stdenv.hostPlatform.isi686 [ 39 # x86 has no arch-specific mega-option, manually enable the options that apply to it 40 (lib.cmakeBool "LD80BITS" true) 41 (lib.cmakeBool "NOALIGN" true) 42 ] 43 ++ [ 44 # Arch dynarec 45 (lib.cmakeBool "ARM_DYNAREC" (withDynarec && stdenv.hostPlatform.isAarch)) 46 ]; 47 48 installPhase = '' 49 runHook preInstall 50 51 install -Dm 0755 box86 "$out/bin/box86" 52 53 runHook postInstall 54 ''; 55 56 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; 57 58 doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; 59 60 installCheckPhase = '' 61 runHook preInstallCheck 62 63 echo Checking if it works 64 $out/bin/box86 -v 65 66 echo Checking if Dynarec option was respected 67 $out/bin/box86 -v | grep ${lib.optionalString (!withDynarec) "-v"} Dynarec 68 69 runHook postInstallCheck 70 ''; 71 72 passthru = { 73 # gitUpdater for local system, otherwise we're cross-compiling gitUpdater 74 updateScript = buildPackages.gitUpdater { rev-prefix = "v"; }; 75 tests.hello = 76 runCommand "box86-test-hello" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } 77 # There is no actual "Hello, world!" with any of the logging enabled, and with all logging disabled it's hard to 78 # tell what problems the emulator has run into. 79 '' 80 BOX86_NOBANNER=0 BOX86_LOG=1 box86 ${lib.getExe hello-x86_32} --version | tee $out 81 ''; 82 }; 83 84 meta = { 85 homepage = "https://box86.org/"; 86 description = "Lets you run x86 Linux programs on non-x86 Linux systems"; 87 changelog = "https://github.com/ptitSeb/box86/releases/tag/v${finalAttrs.version}"; 88 license = lib.licenses.mit; 89 maintainers = with lib.maintainers; [ 90 gador 91 OPNA2608 92 ]; 93 mainProgram = "box86"; 94 platforms = [ 95 "i686-linux" 96 "armv7l-linux" 97 "powerpcle-linux" 98 "loongarch64-linux" 99 "mipsel-linux" 100 ]; 101 }; 102})