diff --git a/pkgs/development/libraries/cosmopolitan/default.nix b/pkgs/development/libraries/cosmopolitan/default.nix index 2af675ccad68..915ee427ef58 100644 --- a/pkgs/development/libraries/cosmopolitan/default.nix +++ b/pkgs/development/libraries/cosmopolitan/default.nix @@ -25,22 +25,10 @@ stdenv.mkDerivation rec { installPhase = '' runHook preInstall - mkdir -p $out/{bin,include,lib} + 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} $out/lib - cat > $out/bin/cosmoc < $out ''; - cosmoc = runCommand "cosmoc-hello" { } '' - printf 'main() { printf("hello world\\n"); }\n' >hello.c - ${cosmopolitan}/bin/cosmoc hello.c - ./a.out - printf "test successful" > $out - ''; }; meta = with lib; { diff --git a/pkgs/development/tools/cosmoc/default.nix b/pkgs/development/tools/cosmoc/default.nix new file mode 100644 index 000000000000..25c4ce52b876 --- /dev/null +++ b/pkgs/development/tools/cosmoc/default.nix @@ -0,0 +1,40 @@ +{ stdenv, lib, cosmopolitan }: + +stdenv.mkDerivation { + pname = "cosmoc"; + inherit (cosmopolitan) version; + + doInstallCheck = true; + dontUnpack = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cat <$out/bin/cosmoc + #!${stdenv.shell} + exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}gcc \ + -O -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \ + "\$@" \ + -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 \ + -fuse-ld=bfd -Wl,-T,${cosmopolitan}/lib/ape.lds \ + -include ${cosmopolitan}/include/cosmopolitan.h \ + ${cosmopolitan}/lib/{crt.o,ape.o,cosmopolitan.a} + 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 = with maintainers; [ lourkeur tomberek ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8576f032457e..a2a0fa1d3574 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16516,6 +16516,8 @@ with pkgs; cog = callPackage ../development/web/cog { }; + cosmoc = callPackage ../development/tools/cosmoc { }; + cosmopolitan = callPackage ../development/libraries/cosmopolitan { }; ctl = callPackage ../development/libraries/ctl { };