diff --git a/pkgs/development/interpreters/racket/default.nix b/pkgs/development/interpreters/racket/default.nix index b5c40f363e3f..adefea1dd036 100644 --- a/pkgs/development/interpreters/racket/default.nix +++ b/pkgs/development/interpreters/racket/default.nix @@ -2,15 +2,10 @@ lib, stdenv, fetchurl, + racket-minimal, - libiconvReal, - libz, - lz4, - ncurses, openssl, - isMinimal ? false, - cairo, fontconfig, glib, @@ -29,10 +24,11 @@ disableDocs ? false, callPackage, - writers, }: let + minimal = racket-minimal.override { inherit disableDocs; }; + makeLibPaths = lib.concatMapStringsSep " " ( lib.flip lib.pipe [ lib.getLib @@ -41,9 +37,12 @@ let ); manifest = lib.importJSON ./manifest.json; - inherit (stdenv.hostPlatform) isDarwin isStatic; + inherit (stdenv.hostPlatform) isDarwin; + + runtimeDeps = [ + openssl + ]; - runtimeDeps = [ openssl ]; mainDistDeps = [ (if isDarwin then libiodbc else unixODBC) cairo @@ -58,83 +57,22 @@ let ]; in -stdenv.mkDerivation (finalAttrs: { - pname = "racket"; - inherit (manifest) version; - - src = - let - info = manifest.${if isMinimal then "minimal" else "full"}; - in - fetchurl { - url = "https://mirror.racket-lang.org/installers/${manifest.version}/${info.filename}"; - inherit (info) sha256; +minimal.overrideAttrs ( + finalAttrs: prevAttrs: { + src = fetchurl { + url = "https://mirror.racket-lang.org/installers/${manifest.version}/${manifest.full.filename}"; + inherit (manifest.full) sha256; }; - nativeBuildInputs = lib.optionals (!isMinimal) [ - wrapGAppsHook3 - ]; - - buildInputs = [ - libiconvReal - libz - lz4 - ncurses - ]; - - patches = lib.optionals isDarwin [ - /* - The entry point binary $out/bin/racket is codesigned at least once. The - following error is triggered as a result. - (error 'add-ad-hoc-signature "file already has a signature") - We always remove the existing signature then call add-ad-hoc-signature to - circumvent this error. - */ - ./patches/force-remove-codesign-then-add.patch - ]; - - preConfigure = - /* - The configure script forces using `libtool -o` as AR on Darwin. But, the - `-o` option is only available from Apple libtool. GNU ar works here. - */ - lib.optionalString isDarwin '' - substituteInPlace src/ChezScheme/zlib/configure \ - --replace-fail 'ARFLAGS="-o"' 'AR=ar; ARFLAGS="rc"' - '' - + '' - mkdir src/build - cd src/build - ''; - - configureScript = "../configure"; - - configureFlags = - [ - "--enable-check" - "--enable-csonly" - "--enable-liblz4" - "--enable-libz" - ] - ++ lib.optional disableDocs "--disable-docs" - ++ lib.optionals (!isStatic) [ - # instead of `--disable-static` that `stdenv` assumes - "--disable-libs" - # "not currently supported" in `configure --help-cs` but still emphasized in README - "--enable-shared" - ] - ++ lib.optionals isDarwin [ - "--disable-strip" - # "use Unix style (e.g., use Gtk) for Mac OS", which eliminates many problems - "--enable-xonx" + nativeBuildInputs = [ + wrapGAppsHook3 ]; - preBuild = - let - libPaths = makeLibPaths mainDistDeps; - libPathsVar = if isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" else "LD_LIBRARY_PATH"; - in - lib.optionalString (!isMinimal) ( + preBuild = + let + libPaths = makeLibPaths mainDistDeps; + libPathsVar = if isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" else "LD_LIBRARY_PATH"; + in /* Makes FFIs available for setting up `main-distribution` and its dependencies, which is integrated into the build process of Racket @@ -148,81 +86,50 @@ stdenv.mkDerivation (finalAttrs: { + '' export FONTCONFIG_FILE=${makeFontsConf { fontDirectories = [ ]; }} export XDG_CACHE_HOME=$(mktemp -d) - '' - ); + ''; - dontStrip = isDarwin; - - preFixup = lib.optionalString (!isMinimal && !isDarwin) '' - gappsWrapperArgs+=("--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive") - ''; - - postFixup = - let - libPaths = makeLibPaths (runtimeDeps ++ lib.optionals (!isMinimal) mainDistDeps); - in - '' - $out/bin/racket -f - < Racket is distributed under the MIT license and the Apache version 2.0 - > license, at your option. - - > The Racket runtime system embeds Chez Scheme, which is distributed - > under the Apache version 2.0 license. - */ - license = with lib.licenses; [ - asl20 - mit - ]; - maintainers = with lib.maintainers; [ rc-zb ]; - mainProgram = "racket"; - platforms = lib.platforms.${if isMinimal then "all" else "unix"}; - badPlatforms = lib.platforms.darwin; - }; -}) + platforms = lib.platforms.unix; + badPlatforms = lib.platforms.darwin; + }; + } +) diff --git a/pkgs/development/interpreters/racket/minimal.nix b/pkgs/development/interpreters/racket/minimal.nix new file mode 100644 index 000000000000..c1abd3f983b1 --- /dev/null +++ b/pkgs/development/interpreters/racket/minimal.nix @@ -0,0 +1,172 @@ +{ + lib, + stdenv, + fetchurl, + + libiconvReal, + libz, + lz4, + ncurses, + openssl, + + disableDocs ? false, + + callPackage, + writers, +}: + +let + manifest = lib.importJSON ./manifest.json; + + inherit (stdenv.hostPlatform) isDarwin isStatic; +in + +stdenv.mkDerivation (finalAttrs: { + pname = "racket"; + inherit (manifest) version; + + src = fetchurl { + url = "https://mirror.racket-lang.org/installers/${manifest.version}/${manifest.minimal.filename}"; + inherit (manifest.minimal) sha256; + }; + + buildInputs = [ + libiconvReal + libz + lz4 + ncurses + ]; + + patches = lib.optionals isDarwin [ + /* + The entry point binary $out/bin/racket is codesigned at least once. The + following error is triggered as a result. + (error 'add-ad-hoc-signature "file already has a signature") + We always remove the existing signature then call add-ad-hoc-signature to + circumvent this error. + */ + ./patches/force-remove-codesign-then-add.patch + ]; + + preConfigure = + /* + The configure script forces using `libtool -o` as AR on Darwin. But, the + `-o` option is only available from Apple libtool. GNU ar works here. + */ + lib.optionalString isDarwin '' + substituteInPlace src/ChezScheme/zlib/configure \ + --replace-fail 'ARFLAGS="-o"' 'AR=ar; ARFLAGS="rc"' + '' + + '' + mkdir src/build + cd src/build + ''; + + configureScript = "../configure"; + + configureFlags = + [ + "--enable-check" + "--enable-csonly" + "--enable-liblz4" + "--enable-libz" + ] + ++ lib.optional disableDocs "--disable-docs" + ++ lib.optionals (!isStatic) [ + # instead of `--disable-static` that `stdenv` assumes + "--disable-libs" + # "not currently supported" in `configure --help-cs` but still emphasized in README + "--enable-shared" + ] + ++ lib.optionals isDarwin [ + "--disable-strip" + # "use Unix style (e.g., use Gtk) for Mac OS", which eliminates many problems + "--enable-xonx" + ]; + + dontStrip = isDarwin; + + postFixup = '' + $out/bin/racket -f - < Racket is distributed under the MIT license and the Apache version 2.0 + > license, at your option. + + > The Racket runtime system embeds Chez Scheme, which is distributed + > under the Apache version 2.0 license. + */ + license = with lib.licenses; [ + asl20 + mit + ]; + maintainers = with lib.maintainers; [ rc-zb ]; + mainProgram = "racket"; + platforms = lib.platforms.all; + badPlatforms = lib.platforms.darwin; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index aa6cdc64dc4f..ab1b2c3e64f4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7285,7 +7285,7 @@ with pkgs; wireplumber = callPackage ../development/libraries/pipewire/wireplumber.nix { }; racket = callPackage ../development/interpreters/racket { }; - racket-minimal = racket.override { isMinimal = true; }; + racket-minimal = callPackage ../development/interpreters/racket/minimal.nix { }; rakudo = callPackage ../development/interpreters/rakudo { }; moarvm = darwin.apple_sdk_11_0.callPackage ../development/interpreters/rakudo/moarvm.nix {