blob: defc3efb8d13d3202394c4ee78c3a2dcd685c1a8 (
plain) (
blame)
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
|
{ lib
, stdenv
, fetchFromGitHub
, bintools-unwrapped
, callPackage
, coreutils
, substituteAll
, unzip
}:
stdenv.mkDerivation (finalAttrs: {
pname = "cosmopolitan";
version = "2.2";
src = fetchFromGitHub {
owner = "jart";
repo = "cosmopolitan";
rev = finalAttrs.version;
hash = "sha256-DTL1dXH+LhaxWpiCrsNjV74Bw5+kPbhEAA2Z1NKiPDk=";
};
patches = [
# make sure tests set PATH correctly
(substituteAll {
src = ./fix-paths.patch;
inherit coreutils;
})
];
nativeBuildInputs = [
bintools-unwrapped
unzip
];
strictDeps = true;
outputs = [ "out" "dist" ];
# slashes are significant because upstream uses o/$(MODE)/foo.o
buildFlags = [
"o/cosmopolitan.h"
"o//cosmopolitan.a"
"o//libc/crt/crt.o"
"o//ape/ape.o"
"o//ape/ape.lds"
];
checkTarget = "o//test";
enableParallelBuilding = true;
doCheck = true;
dontConfigure = true;
dontFixup = true;
preCheck = let
failingTests = [
# some syscall tests fail because we're in a sandbox
"test/libc/calls/sched_setscheduler_test.c"
"test/libc/thread/pthread_create_test.c"
"test/libc/calls/getgroups_test.c"
# fails
"test/libc/stdio/posix_spawn_test.c"
];
in lib.concatStringsSep ";\n" (map (t: "rm -v ${t}") failingTests);
installPhase = ''
runHook preInstall
mkdir -p $out/{include,lib}
install o/cosmopolitan.h $out/include
install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} o/ape/ape-no-modify-self.o $out/lib
cp -RT . "$dist"
runHook postInstall
'';
passthru = {
cosmocc = callPackage ./cosmocc.nix {
cosmopolitan = finalAttrs.finalPackage;
};
};
meta = {
homepage = "https://justine.lol/cosmopolitan/";
description = "Your build-once run-anywhere c library";
license = lib.licenses.isc;
maintainers = lib.teams.cosmopolitan.members;
platforms = lib.platforms.x86_64;
badPlatforms = lib.platforms.darwin;
};
})
|