nixpkgs/pkgs/development/tools/cosmoc/default.nix

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

42 lines
1.1 KiB
Nix
Raw Normal View History

2022-03-29 14:07:44 +02:00
{ stdenv, lib, cosmopolitan }:
stdenv.mkDerivation {
pname = "cosmoc";
inherit (cosmopolitan) version;
doInstallCheck = true;
dontUnpack = true;
dontBuild = true;
2022-08-19 11:39:18 +02:00
# compiler arguments based on upstream README.md
2022-03-29 14:07:44 +02:00
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cat <<EOF >$out/bin/cosmoc
#!${stdenv.shell}
exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}gcc \
2022-08-19 11:39:18 +02:00
-Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
-fno-omit-frame-pointer -pg -mnop-mcount -mno-tls-direct-seg-refs \
2022-03-29 14:07:44 +02:00
"\$@" \
2022-08-19 11:39:18 +02:00
-fuse-ld=bfd -Wl,-T,${cosmopolitan}/lib/ape.lds -Wl,--gc-sections \
2022-03-29 14:07:44 +02:00
-include ${cosmopolitan}/include/cosmopolitan.h \
2022-08-19 11:39:18 +02:00
${cosmopolitan}/lib/{crt.o,ape-no-modify-self.o,cosmopolitan.a}
2022-03-29 14:07:44 +02:00
EOF
chmod +x $out/bin/cosmoc
runHook postInstall
'';
installCheckPhase = ''
printf 'main() { printf("hello world\\n"); }\n' >hello.c
$out/bin/cosmoc hello.c
./a.out
'';
meta = with lib; {
homepage = "https://justine.lol/cosmopolitan/";
description = "compiler for Cosmopolitan C programs";
license = licenses.mit;
maintainers = teams.cosmopolitan.members;
2022-03-29 14:07:44 +02:00
};
}