-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
113 lines (105 loc) · 3.02 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
lib,
pkgsCross,
llvmPackages_17,
replaceVars,
fetchFromGitHub,
cmake,
gitMinimal,
libepoxy,
nasm,
ninja,
pkg-config,
python3,
SDL2,
}:
let
libclang = python3.pkgs.libclang.override { llvmPackages = llvmPackages_17; };
in
llvmPackages_17.stdenv.mkDerivation (finalAttrs: {
pname = "fex";
version = "2408";
src = fetchFromGitHub {
owner = "FEX-Emu";
repo = "FEX";
rev = "FEX-${finalAttrs.version}";
hash = "sha256-6V9LDZm1dxm301JBjfk7+9J+QbkvMLMRZW9Tzip4LwM=";
fetchSubmodules = true;
};
patches =
[
# These aren't strictly needed.
#
# This is a workaround to get FEX working within Nix's build sandbox: FEX's
# tests will break without it, but you can fix that with `export HOME=$PWD`.
#
# TODO: upstream this one.
./check-home.patch
# This is a workaround to get FEX working with NixOS's slightly weird binfmt
# infrastructure.
./realpath.patch
]
++ lib.optionals finalAttrs.finalPackage.doCheck [
(replaceVars ./cross-includes.patch {
# These versions of glibc are the versions used by `stdenv.cc`, meaning that
# they're already in the binary cache as a result of Hydra building it.
i686Libs = pkgsCross.gnu32.stdenv.cc.libc_dev;
x86_64Libs = pkgsCross.gnu64.stdenv.cc.libc_dev;
})
];
nativeBuildInputs = [
cmake
gitMinimal
llvmPackages_17.bintools # for lld
ninja
pkg-config
python3
python3.pkgs.setuptools
];
buildInputs = [
libepoxy
SDL2
];
cmakeFlags = [
"-DUSE_LINKER=lld"
(lib.cmakeBool "BUILD_TESTS" finalAttrs.finalPackage.doCheck)
];
doCheck = true;
nativeCheckInputs = [
nasm
libclang
];
preCheck = ''
patchelf \
--set-interpreter ${pkgsCross.gnu64.stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 \
$(find ../External/{fex-posixtest-bins/conformance,fex-gvisor-tests-bins,fex-gcc-target-tests-bins/64} -type f -executable)
patchelf \
--add-rpath ${pkgsCross.gnu64.gcc.cc.lib}/lib \
$(find ../External/fex-gvisor-tests-bins -type f -executable)
patchelf \
--set-interpreter ${pkgsCross.gnu32.stdenv.cc.libc}/lib/ld-linux.so.2 \
$(find ../External/fex-gcc-target-tests-bins/32 -type f -executable)
# These all seem to fail due to the build sandbox.
echo -n '
conformance-interfaces-sched_setparam-26-1.test
conformance-interfaces-sigqueue-12-1.test
conformance-interfaces-sigqueue-3-1.test
' >> ../unittests/POSIX/Known_Failures
echo -n '
dev_test
getcpu_host_test
getcpu_test
lseek_test
tuntap_test
write_test
' >> ../unittests/gvisor-tests/Known_Failures
# For some reason this test fails in darwin.linux-builder, and passes in a UTM
# VM; paper over the difference by disabling it.
echo 'write_test' >> ../unittests/gvisor-tests/Disabled_Tests
'';
meta = {
description = "Fast usermode x86 and x86-64 emulator for Arm64 Linux";
homepage = "https://fex-emu.com";
license = lib.licenses.mit;
};
})