-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpkg.nix
More file actions
73 lines (65 loc) · 2.03 KB
/
pkg.nix
File metadata and controls
73 lines (65 loc) · 2.03 KB
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
{
lib,
stdenv,
fetchFromGitHub,
pkgsBuildHost,
targetPackages,
# Others
flags ? [ ],
}:
let
isCross = stdenv.buildPlatform.system != stdenv.targetPlatform.system;
isSameOS = stdenv.buildPlatform.parsed.kernel.name == stdenv.targetPlatform.parsed.kernel.name;
glibcVersion = if stdenv.targetPlatform.isLoongArch64 then ".2.36" else ".2.28";
muslVersion = if stdenv.targetPlatform.isLoongArch64 then "" else "";
abiVersion =
if stdenv.targetPlatform.isGnu then
glibcVersion
else if stdenv.targetPlatform.isMusl then
muslVersion
else
(throw "not supported abi version ${stdenv.targetPlatform.parsed.abi.name}");
zigTarget =
if stdenv.targetPlatform.isLinux && stdenv.targetPlatform.is32bit then
"-Dtarget=${stdenv.targetPlatform.parsed.cpu.family}-linux-${stdenv.targetPlatform.parsed.abi.name}${abiVersion}"
else if stdenv.targetPlatform.isLinux then
"-Dtarget=${stdenv.targetPlatform.parsed.cpu.name}-linux-${stdenv.targetPlatform.parsed.abi.name}${abiVersion}"
else if stdenv.targetPlatform.isDarwin then
"-Dtarget=${stdenv.targetPlatform.parsed.cpu.name}-macos.${stdenv.targetPlatform.darwinSdkVersion}"
else
(throw "not supported target");
in
stdenv.mkDerivation {
name = "debuginfod-zig";
version = "0.194";
src = ./.;
preBuild = ''
export ZIG_GLOBAL_CACHE_DIR=$TMPDIR
'';
zigBuildFlags = [
zigTarget
]
++ flags;
postInstall =
let
ld =
if stdenv.targetPlatform.isLinux then
"$(echo ${targetPackages.stdenv.cc.bintools.dynamicLinker})"
else
"";
qemu =
if stdenv.targetPlatform.isLinux && isCross then
"${pkgsBuildHost.qemu-user}/bin/qemu-${stdenv.targetPlatform.qemuArch}"
else
"";
in
lib.optionalString isSameOS ''
echo "Starting tests..."
${qemu} ${ld} $out/bin/test
'';
# Allow tests that bind or connect to localhost on macOS.
__darwinAllowLocalNetworking = true;
nativeBuildInputs = [
pkgsBuildHost.dev_zig_0_16.hook
];
}