nixpkgs/pkgs/by-name/co/cosmopolitan/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
2.0 KiB
Nix
Raw Normal View History

2023-10-17 02:04:31 +00:00
{ lib
, stdenv
, fetchFromGitHub
, bintools-unwrapped
, callPackage
2023-10-17 02:04:31 +00:00
, coreutils
, substituteAll
, unzip
}:
2023-10-17 02:04:31 +00:00
stdenv.mkDerivation (finalAttrs: {
pname = "cosmopolitan";
2023-02-12 18:00:32 +00:00
version = "2.2";
src = fetchFromGitHub {
owner = "jart";
2023-10-17 02:04:31 +00:00
repo = "cosmopolitan";
rev = finalAttrs.version;
hash = "sha256-DTL1dXH+LhaxWpiCrsNjV74Bw5+kPbhEAA2Z1NKiPDk=";
};
patches = [
# make sure tests set PATH correctly
2023-10-17 02:04:31 +00:00
(substituteAll {
src = ./fix-paths.patch;
inherit coreutils;
})
];
2023-10-17 02:04:31 +00:00
nativeBuildInputs = [
bintools-unwrapped
unzip
];
strictDeps = true;
2022-03-29 16:00:16 +00:00
outputs = [ "out" "dist" ];
2022-03-29 08:45:33 +00:00
# slashes are significant because upstream uses o/$(MODE)/foo.o
2023-10-17 02:04:31 +00:00
buildFlags = [
"o/cosmopolitan.h"
"o//cosmopolitan.a"
"o//libc/crt/crt.o"
"o//ape/ape.o"
"o//ape/ape.lds"
];
2022-03-29 12:22:39 +00:00
checkTarget = "o//test";
2023-10-17 02:04:31 +00:00
2022-03-29 12:22:39 +00:00
enableParallelBuilding = true;
doCheck = true;
dontConfigure = true;
dontFixup = true;
2023-10-17 02:04:31 +00:00
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
2023-10-17 02:04:31 +00:00
2022-03-29 12:07:44 +00:00
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
2022-03-29 16:00:16 +00:00
cp -RT . "$dist"
2023-10-17 02:04:31 +00:00
runHook postInstall
'';
passthru = {
cosmocc = callPackage ./cosmocc.nix {
cosmopolitan = finalAttrs.finalPackage;
};
};
2023-10-17 02:04:31 +00:00
meta = {
homepage = "https://justine.lol/cosmopolitan/";
description = "Your build-once run-anywhere c library";
2023-10-17 02:04:31 +00:00
license = lib.licenses.isc;
maintainers = lib.teams.cosmopolitan.members;
platforms = lib.platforms.x86_64;
badPlatforms = lib.platforms.darwin;
};
2023-10-17 02:04:31 +00:00
})