diff --git a/pkgs/by-name/ch/chez/package.nix b/pkgs/by-name/ch/chez/package.nix index 7cfb7e682c43..42035a6a82ba 100644 --- a/pkgs/by-name/ch/chez/package.nix +++ b/pkgs/by-name/ch/chez/package.nix @@ -1,26 +1,54 @@ { lib, stdenv, - fetchurl, - coreutils, + fetchFromGitHub, + zuo, + zlib, + lz4, + libffi, cctools, darwin, ncurses, libiconv, libX11, - libuuid, testers, -}@args: + writableTmpDirAsHomeHook, + buildPackages, +}: +let + inherit (stdenv.hostPlatform) extensions; + arch = + { + "x86_64-linux" = "ta6le"; + "x86-linux" = "ti3le"; + "aarch64-linux" = "tarm64le"; + "x86_64-darwin" = "ta6osx"; + "aarch64-darwin" = "tarm64osx"; + "x86_64-windows" = "ta6nt"; + "aarch64-windows" = "tarm64nt"; + } + .${stdenv.hostPlatform.system} + or (throw "Unsupported host system, try checking https://cisco.github.io/ChezScheme/release_notes/latest/release_notes.html to see if ${stdenv.hostPlatform.system} is supported"); +in stdenv.mkDerivation (finalAttrs: { pname = "chez-scheme"; version = "10.2.0"; - src = fetchurl { - url = "https://github.com/cisco/ChezScheme/releases/download/v${finalAttrs.version}/csv${finalAttrs.version}.tar.gz"; - hash = "sha256-t5WRbUz+1ZJAxfRLG1B6hlfv0o5i5y4TTQNIbp8+N0o="; + src = fetchFromGitHub { + owner = "cisco"; + repo = "ChezScheme"; + tag = "v${finalAttrs.version}"; + hash = "sha256-wAEnuC6hktCK/l00G48jYD9fwdyiXkzHjC2YYVeCJXo="; + # Vendored nanopass and stex + fetchSubmodules = true; }; + strictDeps = true; + depsBuildBuild = [ + zuo # Used as the build driver + buildPackages.stdenv.cc # Needed for cross + ]; nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ cctools @@ -28,42 +56,54 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ darwin.autoSignDarwinBinariesHook ]; + buildInputs = [ ncurses libiconv + zlib + lz4 + libffi + ] + ++ lib.optionals stdenv.hostPlatform.isUnix [ libX11 - libuuid ]; - enableParallelBuilding = true; - - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation"; - /* - ** We have to fix a few occurrences to tools with absolute - ** paths in some helper scripts, otherwise the build will fail on - ** NixOS or in any chroot build. - */ - patchPhase = '' - substituteInPlace ./makefiles/installsh \ - --replace-warn "/usr/bin/true" "${coreutils}/bin/true" - - substituteInPlace zlib/configure \ - --replace-warn "/usr/bin/libtool" libtool - ''; - - /* - ** Don't use configureFlags, since that just implicitly appends - ** everything onto a --prefix flag, which ./configure gets very angry - ** about. + ** Set to use Nixpkgs dependencies when possible + ** instead of vendored dependencies. ** - ** Also, carefully set a manual workarea argument, so that we + ** Carefully set a manual workarea argument, so that we ** can later easily find the machine type that we built Chez ** for. */ - configurePhase = '' - ./configure --as-is --threads --installprefix=$out --installman=$out/share/man - ''; + enableParallelBuilding = true; + dontAddPrefix = true; + configurePlatforms = [ ]; # So it doesn't add the default --build --host flags + configureFlags = [ + # Skip submodule update + "--as-is" + # Threaded version + "--threads" + "--installprefix=${placeholder "out"}" + "--installman=${placeholder "out"}/share/man" + "--enable-libffi" + "CC_FOR_BUILD=cc" + # Use Nixpkgs dependencies + "ZUO=zuo" + "ZLIB=${zlib}/lib/libz${extensions.sharedLibrary}" + "LZ4=${lz4.lib}/lib/liblz4${extensions.sharedLibrary}" + # Append to CFLAGS or else get errors + # Don't set CFLAGS so it can do some detections stuff + "CFLAGS+=${lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation"}" + ] + ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "--cross" + "-m=${arch}" + ]; + + enableParallelChecking = true; + nativeCheckInputs = [ writableTmpDirAsHomeHook ]; + doCheck = false; # Filesystem checks are impure # ** Clean up some of the examples from the build output. postInstall = '' @@ -72,18 +112,20 @@ stdenv.mkDerivation (finalAttrs: { setupHook = ./setup-hook.sh; - passthru.tests = { - version = testers.testVersion { - package = finalAttrs.finalPackage; - }; + passthru.tests.version = testers.testVersion { + package = finalAttrs.finalPackage; }; meta = { description = "Powerful and incredibly fast R6RS Scheme compiler"; homepage = "https://cisco.github.io/ChezScheme/"; + changelog = "https://cisco.github.io/ChezScheme/release_notes/v${finalAttrs.version}/release_notes.html"; license = lib.licenses.asl20; - maintainers = with lib.maintainers; [ thoughtpolice ]; - platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ + thoughtpolice + RossSmyth + ]; + platforms = lib.platforms.all; mainProgram = "scheme"; }; })