From d3f1b7d32d619ef3cf6b469c324086fe5d0e1b11 Mon Sep 17 00:00:00 2001 From: Las Safin Date: Wed, 22 Dec 2021 16:31:39 +0000 Subject: [PATCH 1/2] chez-racket: init at 2021-12-11 --- .../compilers/chez-racket/default.nix | 52 +++++++++++++++++++ .../compilers/chez-racket/setup-hook.sh | 5 ++ .../compilers/chez-racket/shared.nix | 41 +++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 100 insertions(+) create mode 100644 pkgs/development/compilers/chez-racket/default.nix create mode 100644 pkgs/development/compilers/chez-racket/setup-hook.sh create mode 100644 pkgs/development/compilers/chez-racket/shared.nix diff --git a/pkgs/development/compilers/chez-racket/default.nix b/pkgs/development/compilers/chez-racket/default.nix new file mode 100644 index 0000000000000..fa32934243c6d --- /dev/null +++ b/pkgs/development/compilers/chez-racket/default.nix @@ -0,0 +1,52 @@ +{ stdenv, buildPackages, callPackage }: + +let + chezSystemMap = { + # See `/workarea` of source code for list of systems + "aarch64-darwin" = "tarm64osx"; + "aarch64-linux" = "tarm64le"; + "armv7l-linux" = "tarm32le"; + "x86_64-darwin" = "ta6osx"; + "x86_64-linux" = "ta6le"; + }; + inherit (stdenv.hostPlatform) system; + chezSystem = chezSystemMap.${system} or (throw "Add ${system} to chezSystemMap to enable building chez-racket"); + # Chez Scheme uses an ad-hoc `configure`, hence we don't use the usual + # stdenv abstractions. + forBoot = { + pname = "chez-scheme-racket-boot"; + configurePhase = '' + runHook preConfigure + ./configure --pb ZLIB=$ZLIB LZ4=$LZ4 + runHook postConfigure + ''; + makeFlags = [ "${chezSystem}.bootquick" ]; + installPhase = '' + runHook preInstall + mkdir -p $out + pushd boot + mv $(ls -1 | grep -v "^pb$") -t $out + popd + runHook postInstall + ''; + }; + boot = buildPackages.callPackage (import ./shared.nix forBoot) {}; + forFinal = { + pname = "chez-scheme-racket"; + configurePhase = '' + runHook preConfigure + cp -r ${boot}/* -t ./boot + ./configure -m=${chezSystem} --installprefix=$out --installman=$out/share/man ZLIB=$ZLIB LZ4=$LZ4 + runHook postConfigure + ''; + preBuild = '' + pushd ${chezSystem}/c + ''; + postBuild = '' + popd + ''; + setupHook = ./setup-hook.sh; + }; + final = callPackage (import ./shared.nix forFinal) {}; +in +final diff --git a/pkgs/development/compilers/chez-racket/setup-hook.sh b/pkgs/development/compilers/chez-racket/setup-hook.sh new file mode 100644 index 0000000000000..1d81489bd4e46 --- /dev/null +++ b/pkgs/development/compilers/chez-racket/setup-hook.sh @@ -0,0 +1,5 @@ +addChezLibraryPath() { + addToSearchPath CHEZSCHEMELIBDIRS "$1/lib/csv-site" +} + +addEnvHooks "$targetOffset" addChezLibraryPath diff --git a/pkgs/development/compilers/chez-racket/shared.nix b/pkgs/development/compilers/chez-racket/shared.nix new file mode 100644 index 0000000000000..06c1419fea6ca --- /dev/null +++ b/pkgs/development/compilers/chez-racket/shared.nix @@ -0,0 +1,41 @@ +args: +{ stdenv, lib, fetchFromGitHub, coreutils, darwin +, ncurses, libiconv, libX11, zlib, lz4 +}: + +stdenv.mkDerivation (args // { + version = "unstable-2021-12-11"; + + src = fetchFromGitHub { + owner = "racket"; + repo = "ChezScheme"; + rev = "8846c96b08561f05a937d5ecfe4edc96cc99be39"; + sha256 = "IYJQzT88T8kFahx2BusDOyzz6lQDCbZIfSz9rZoNF7A="; + fetchSubmodules = true; + }; + + prePatch = '' + rm -rf zlib/*.c lz4/lib/*.c + ''; + + postPatch = '' + export ZLIB="$(find ${zlib.out}/lib -type f | sort | head -n1)" + export LZ4="$(find ${lz4.out}/lib -type f | sort | head -n1)" + ''; + + nativeBuildInputs = lib.optional stdenv.isDarwin darwin.cctools; + buildInputs = [ ncurses libX11 zlib lz4 ] + ++ lib.optional stdenv.isDarwin libiconv; + + enableParallelBuilding = true; + + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation"; + + meta = { + description = "Fork of Chez Scheme for Racket"; + homepage = "https://github.com/racket/ChezScheme"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ l-as ]; + platforms = lib.platforms.unix; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 12e98976b70ee..3dba2ae0965ae 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11599,6 +11599,8 @@ with pkgs; inherit (darwin) cctools; }; + chez-racket = callPackage ../development/compilers/chez-racket {}; + chez-srfi = callPackage ../development/chez-modules/chez-srfi { }; chez-mit = callPackage ../development/chez-modules/chez-mit { }; From 177e4ff31fc51726eebb09b8a2b0b15c791c26a4 Mon Sep 17 00:00:00 2001 From: Las Safin Date: Thu, 23 Dec 2021 21:14:28 +0000 Subject: [PATCH 2/2] chez-racket: Fix signing on Darwin (Thanks @Steven0351!) --- pkgs/development/compilers/chez-racket/shared.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/chez-racket/shared.nix b/pkgs/development/compilers/chez-racket/shared.nix index 06c1419fea6ca..f5a9bbc1e5b4b 100644 --- a/pkgs/development/compilers/chez-racket/shared.nix +++ b/pkgs/development/compilers/chez-racket/shared.nix @@ -23,7 +23,7 @@ stdenv.mkDerivation (args // { export LZ4="$(find ${lz4.out}/lib -type f | sort | head -n1)" ''; - nativeBuildInputs = lib.optional stdenv.isDarwin darwin.cctools; + nativeBuildInputs = lib.optionals stdenv.isDarwin (with darwin; [ cctools autoSignDarwinBinariesHook ]); buildInputs = [ ncurses libX11 zlib lz4 ] ++ lib.optional stdenv.isDarwin libiconv;