From 2a1379f62917e1dbed388f255b4d46100015a365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claes=20Wallin=20=28=E9=9F=8B=E5=98=89=E8=AA=A0=29?= Date: Sat, 24 Feb 2018 23:05:16 +0800 Subject: [PATCH 1/3] Problem: We are not running raco setup We skipped raco setup before, because we ran into some issues. Time to resolve them. - We would start copying manpages and things already installed in our dependencies. - We would fail on multi-collection packages because setup assumed some directories would be there. Unclear why, they're not there when the full racket install runs setup. It's probably provoked by our multiple collects-directories setup. Solution: - Use --only --pkgs to only run setup for the relevant package. (--pkgs: Not everything, --only: Not even our dependencies) - Create directories for all the collections we are setting up. - After setup, prune any empty directories in .../collects, including collects itself. We don't need them when setup is done. Closes #23 --- racket2nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/racket2nix b/racket2nix index b12b4ba..ccddb5d 100755 --- a/racket2nix +++ b/racket2nix @@ -65,7 +65,29 @@ stdenv.mkDerivation rec { # install and link us if ${racket-cmd} -e "(require pkg/lib) (exit (if (member \"$name\" (installed-pkg-names #:scope (bytes->path (string->bytes/utf-8 \"${_racket-lib.out}/share/racket/pkgs\")))) 1 0))"; then ${raco} pkg install --no-setup --copy --deps fail --fail-fast --scope installation ./$name + collection_name=$(${racket-cmd} -e "(require setup/getinfo) ((get-info/full \"$name\") 'collection)") + ( + shopt -s nullglob + case "$collection_name" in + "'multi") + collection_names=$(for collection_path in $out/share/racket/pkgs/$name/*/; do + basename $collection_path; done) + ;; + "'use-pkg-name") + collection_names=$name + ;; + '"'*'"') + collection_names=$(echo $collection_name | tr -d '"') + ;; + *) + echo >&2 "Unexpected info.rkt value: ('collection . $collection_name)" + exit 2 + esac + mkdir -p $(printf "$out/share/racket/collects/%s " $collection_names) + ) + ${raco} setup --no-user --no-pkg-deps --fail-fast --only --pkgs $name fi + find $out/share/racket/collects -type d -empty -delete ''; } EOM From 3e922a816b1be866ac228fca3ea869c4eae9832c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claes=20Wallin=20=28=E9=9F=8B=E5=98=89=E8=AA=A0=29?= Date: Sat, 24 Feb 2018 23:15:17 +0800 Subject: [PATCH 2/3] Problem: raco setup is really slow setup doesn't understand that it's already compiled when the compiled files are not in the default destination, so it keeps compiling itself and other things, including compiling the compiler. Solution: As a workaround, symlink everything into our main collects directory. After setup, remove it again. --- racket2nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/racket2nix b/racket2nix index ccddb5d..7f42236 100755 --- a/racket2nix +++ b/racket2nix @@ -62,6 +62,13 @@ stdenv.mkDerivation rec { echo ${racket-cmd} + mkdir -p $out/share/racket/collects/ + for bootstrap_collection in racket compiler syntax setup openssl ffi file pkg planet; do + cp -rs ${racket.out}/share/racket/collects/$bootstrap_collection \ + $out/share/racket/collects/ + done + find $out/share/racket/collects -type d -exec chmod 755 {} + + # install and link us if ${racket-cmd} -e "(require pkg/lib) (exit (if (member \"$name\" (installed-pkg-names #:scope (bytes->path (string->bytes/utf-8 \"${_racket-lib.out}/share/racket/pkgs\")))) 1 0))"; then ${raco} pkg install --no-setup --copy --deps fail --fail-fast --scope installation ./$name @@ -87,6 +94,7 @@ stdenv.mkDerivation rec { ) ${raco} setup --no-user --no-pkg-deps --fail-fast --only --pkgs $name fi + find $out/share/racket/collects -lname '${_racket-lib.out}/share/racket/collects/*' -delete find $out/share/racket/collects -type d -empty -delete ''; } From be12a29fecbbff19adacf44cc6aaccf35e514eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claes=20Wallin=20=28=E9=9F=8B=E5=98=89=E8=AA=A0=29?= Date: Sat, 24 Feb 2018 23:36:12 +0800 Subject: [PATCH 3/3] Problem: drracket and racket-doc will not build on MacOS Solution: Raise the soft max-files limit. Instruct the user how to raise the hard limit, if necessary. --- racket2nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/racket2nix b/racket2nix index 7f42236..2746ea3 100755 --- a/racket2nix +++ b/racket2nix @@ -37,6 +37,7 @@ stdenv.mkDerivation rec { racket-cmd = "${racket.out}/bin/racket -G $out/etc/racket -U -X $out/share/racket/collects"; raco = "${racket-cmd} -N raco -l- raco"; + maxFileDescriptors = 2048; passAsFile = [ "racketConfig" ]; @@ -52,6 +53,17 @@ stdenv.mkDerivation rec { ''; installPhase = '' + if ! ulimit -n $maxFileDescriptors; then + echo >&2 If the number of allowed file descriptors is lower than ~2048,' + echo >&2 packages like drracket or racket-doc will not build correctly. + echo >&2 If raising the soft limit fails '(like it just did)', you will + echo >&2 have to raise the hard limit on your operating system. + echo >&2 Examples: + echo >&2 debian: https://unix.stackexchange.com/questions/127778 + echo >&2 MacOS: https://superuser.com/questions/117102 + exit 2 + fi + mkdir -p $out/etc/racket $out/share/racket sed -e 's|$out|'"$out|g" > $out/etc/racket/config.rktd < $racketConfigPath