2022-09-22 12:36:57 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, unzip, bintools-unwrapped, coreutils, substituteAll }:
|
2021-04-17 00:35:05 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2021-04-17 00:35:05 +00:00
|
|
|
pname = "cosmopolitan";
|
2022-10-21 18:38:19 +00:00
|
|
|
version = "2.1.1";
|
2021-04-17 00:35:05 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jart";
|
2022-09-22 12:36:57 +00:00
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-2Q4lutSIQ6tBwTy01lPSMepNAww9Kb7BwNyEcsSdWZ0=";
|
2021-04-17 00:35:05 +00:00
|
|
|
};
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
patches = [
|
|
|
|
# make sure tests set PATH correctly
|
|
|
|
(substituteAll { src = ./fix-paths.patch; inherit coreutils; })
|
|
|
|
];
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
nativeBuildInputs = [ bintools-unwrapped unzip ];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
outputs = [ "out" "dist" ];
|
2021-04-17 00:35:05 +00:00
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
# 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;
|
2021-04-17 00:35:05 +00:00
|
|
|
dontConfigure = true;
|
|
|
|
dontFixup = true;
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
preCheck = ''
|
|
|
|
# some syscall tests fail because we're in a sandbox
|
|
|
|
rm test/libc/calls/sched_setscheduler_test.c
|
2022-09-30 11:47:45 +00:00
|
|
|
rm test/libc/thread/pthread_create_test.c
|
|
|
|
rm test/libc/calls/getgroups_test.c
|
2022-09-22 12:36:57 +00:00
|
|
|
'';
|
|
|
|
|
2021-04-17 00:35:05 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2022-04-03 18:54:34 +00:00
|
|
|
mkdir -p $out/{include,lib}
|
2022-03-30 09:31:56 +00:00
|
|
|
install o/cosmopolitan.h $out/include
|
2022-09-22 12:36:57 +00:00
|
|
|
install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} o/ape/ape-no-modify-self.o $out/lib
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
cp -RT . "$dist"
|
2021-04-17 00:35:05 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://justine.lol/cosmopolitan/";
|
|
|
|
description = "Your build-once run-anywhere c library";
|
|
|
|
platforms = platforms.x86_64;
|
|
|
|
badPlatforms = platforms.darwin;
|
|
|
|
license = licenses.isc;
|
2022-04-03 18:54:34 +00:00
|
|
|
maintainers = teams.cosmopolitan.members;
|
2021-04-17 00:35:05 +00:00
|
|
|
};
|
|
|
|
}
|