diff --git a/maintainers/team-list.nix b/maintainers/team-list.nix index 66cba166f2ca..8076edacd81a 100644 --- a/maintainers/team-list.nix +++ b/maintainers/team-list.nix @@ -70,6 +70,14 @@ with lib.maintainers; { scope = "Maintain the Chia blockchain and its dependencies"; }; + cosmopolitan = { + members = [ + lourkeur + tomberek + ]; + scope = "Maintain the Cosmopolitan LibC and related programs."; + }; + deshaw = { # Verify additions to this team with at least one already existing member of the team. members = [ diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index 0c5b3b4fec76..66bc74310c9e 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -1253,6 +1253,13 @@ example. + + + pkgs.cosmopolitan no longer provides the + cosmoc command. It has been moved to + pkgs.cosmoc. + +
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index 7cafdcabbaaf..64fa68ddc620 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -444,6 +444,8 @@ In addition to numerous new and upgraded packages, this release has the followin See the `vscode` package for a more detailed example. +- `pkgs.cosmopolitan` no longer provides the `cosmoc` command. It has been moved to `pkgs.cosmoc`. + ## Other Notable Changes {#sec-release-22.05-notable-changes} diff --git a/pkgs/development/interpreters/python-cosmopolitan/default.nix b/pkgs/development/interpreters/python-cosmopolitan/default.nix new file mode 100644 index 000000000000..14459a24aac2 --- /dev/null +++ b/pkgs/development/interpreters/python-cosmopolitan/default.nix @@ -0,0 +1,39 @@ +{ lib, stdenv, cosmopolitan, unzip, bintools-unwrapped }: + +stdenv.mkDerivation rec { + pname = "python-cosmopolitan"; + version = "3.6.14"; + + src = cosmopolitan.dist; + + patches = [ + ./ioctl.patch # required /dev/tty + ]; + + nativeBuildInputs = [ bintools-unwrapped unzip ]; + + # slashes are significant because upstream uses o/$(MODE)/foo.o + buildFlags = "o//third_party/python"; + checkTarget = "o//third_party/python/test"; + enableParallelBuilding = true; + + doCheck = true; + dontConfigure = true; + dontFixup = true; + + installPhase = '' + runHook preInstall + install o/third_party/python/*.com -Dt $out/bin + runHook postInstall + ''; + + meta = with lib; { + homepage = "https://justine.lol/cosmopolitan/"; + description = "Actually Portable Python using Cosmopolitan"; + platforms = platforms.x86_64; + badPlatforms = platforms.darwin; + license = licenses.isc; + maintainers = teams.cosmopolitan.members; + mainProgram = "python.com"; + }; +} diff --git a/pkgs/development/libraries/cosmopolitan/ioctl.patch b/pkgs/development/interpreters/python-cosmopolitan/ioctl.patch similarity index 100% rename from pkgs/development/libraries/cosmopolitan/ioctl.patch rename to pkgs/development/interpreters/python-cosmopolitan/ioctl.patch diff --git a/pkgs/development/libraries/cosmopolitan/default.nix b/pkgs/development/libraries/cosmopolitan/default.nix index ca303fdeaea3..f58e654cbfe3 100644 --- a/pkgs/development/libraries/cosmopolitan/default.nix +++ b/pkgs/development/libraries/cosmopolitan/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, runCommand, unzip, cosmopolitan,bintools-unwrapped }: +{ lib, stdenv, fetchFromGitHub, unzip, bintools-unwrapped }: stdenv.mkDerivation rec { pname = "cosmopolitan"; @@ -11,72 +11,35 @@ stdenv.mkDerivation rec { sha256 = "sha256-UjL4wR5HhuXiQXg6Orcx2fKiVGRPMJk15P779BP1fRA="; }; - patches = [ - ./ioctl.patch # required /dev/tty - ]; + nativeBuildInputs = [ bintools-unwrapped unzip ]; - postPatch = '' - patchShebangs build/ - ''; + outputs = [ "out" "dist" ]; + # 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; dontConfigure = true; dontFixup = true; - enableParallelBuilding = true; - nativeBuildInputs = [ bintools-unwrapped unzip ]; 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 <hello.c - ${stdenv.cc}/bin/gcc -g -O -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone -o hello.com.dbg hello.c \ - -fuse-ld=bfd -Wl,-T,${cosmopolitan}/lib/ape.lds \ - -include ${cosmopolitan}/include/cosmopolitan.h \ - -I ${cosmopolitan}/include \ - ${cosmopolitan}/lib/{crt.o,ape.o,cosmopolitan.a} - ${stdenv.cc.bintools.bintools_bin}/bin/objcopy -S -O binary hello.com.dbg hello.com - ./hello.com - printf "test successful" > $out - ''; - cosmoc = runCommand "cosmoc-hello" { } '' - printf '#include "libc/stdio/stdio.h"\nmain() { printf("hello world\\n"); }\n' >hello.c - ${cosmopolitan}/bin/cosmoc hello.c - ./a.out - printf "test successful" > $out - ''; - }; - 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; - maintainers = with maintainers; [ lourkeur tomberek ]; + maintainers = teams.cosmopolitan.members; }; } diff --git a/pkgs/development/tools/cosmoc/default.nix b/pkgs/development/tools/cosmoc/default.nix new file mode 100644 index 000000000000..f1e80d91df55 --- /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 = teams.cosmopolitan.members; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 59cd11132018..3dd27785c49e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16534,8 +16534,12 @@ with pkgs; cog = callPackage ../development/web/cog { }; + cosmoc = callPackage ../development/tools/cosmoc { }; + cosmopolitan = callPackage ../development/libraries/cosmopolitan { }; + python-cosmopolitan = callPackage ../development/interpreters/python-cosmopolitan { }; + ctl = callPackage ../development/libraries/ctl { }; ctpp2 = callPackage ../development/libraries/ctpp2 { };