Commit 3666c314 authored by Anderson Torres's avatar Anderson Torres
Browse files

cosmocc: move to cosmopolitan

Also, a refactor.
parent 037d5af0
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
{ runCommand, cosmopolitan }:

let
  cosmocc = runCommand "cosmocc-${cosmopolitan.version}"
    {
      pname = "cosmocc";
      inherit (cosmopolitan) version;

      passthru.tests = {
        cc = runCommand "c-test" { } ''
          ${cosmocc}/bin/cosmocc ${./hello.c}
          ./a.out > $out
        '';
      };

      meta = cosmopolitan.meta // {
        description = "compilers for Cosmopolitan C/C++ programs";
      };
    } ''
        mkdir -p $out/bin
        install ${cosmopolitan.dist}/tool/scripts/{cosmocc,cosmoc++} $out/bin
        sed 's|/opt/cosmo\([ /]\)|${cosmopolitan.dist}\1|g' -i $out/bin/*
      '';
in
cosmocc
+6 −0
Original line number Diff line number Diff line
#include <stdio.h>

int main() {
    printf("Hello world!\n");
    return 0;
}
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
, stdenv
, fetchFromGitHub
, bintools-unwrapped
, callPackage
, coreutils
, substituteAll
, unzip
@@ -74,6 +75,12 @@ stdenv.mkDerivation (finalAttrs: {
    runHook postInstall
  '';

  passthru = {
    cosmocc = callPackage ./cosmocc.nix {
      cosmopolitan = finalAttrs.finalPackage;
    };
  };

  meta = {
    homepage = "https://justine.lol/cosmopolitan/";
    description = "Your build-once run-anywhere c library";
+0 −34
Original line number Diff line number Diff line
{ runCommand, cosmopolitan }:

let
  inherit (cosmopolitan) version;

  cosmocc =
    runCommand "cosmocc-${version}"
      {
        pname = "cosmocc";
        inherit version;

        meta = cosmopolitan.meta // {
          description = "compilers for Cosmopolitan C/C++ programs";
        };
        passthru.tests = {
          cc = runCommand "c-test" { } ''
            cat > hello.c << END
            #include <stdio.h>
            int main() {
              printf("Hello world!\n");
              return 0;
            }
            END
            ${cosmocc}/bin/cosmocc hello.c
            ./a.out > $out
          '';
        };
      } ''
      mkdir -p $out/bin
      install ${cosmopolitan.dist}/tool/scripts/{cosmocc,cosmoc++} $out/bin
      sed 's|/opt/cosmo\([ /]\)|${cosmopolitan.dist}\1|g' -i $out/bin/*
    '';
in
cosmocc
+1 −1
Original line number Diff line number Diff line
@@ -20921,7 +20921,7 @@ with pkgs;
  cog = callPackage ../development/web/cog { };
  cosmocc = callPackage ../development/tools/cosmocc { };
  inherit (cosmopolitan) cosmocc;
  python-cosmopolitan = callPackage ../development/interpreters/python-cosmopolitan { };