From ab21a84e0a24bb3f7286a7f8562cd9f2571c233a 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: Wed, 28 Feb 2018 03:19:50 +0800 Subject: [PATCH] Problem: drracket doesn't build There are some circular dependencies in there. They can be made to work. The top package is the one that was detected as a circular dependency by the bottom package and was cut out of the circle. The top package transitively depends on the rest of the circle, the others are cut off at the bottom package. Here's how we can make this work: 1. Don't run setup on any bottom package. There are some true circular dependencies in there, that won't work unless the dependency has had a proper setup and registered its collections. They can be made to work by doing some extra work in the top (not necessarily, but we were lucky enough that it was the top -- the circle was only two packages) package: 2a. Remove the bottom package from the config.rktd dependencies. 2b. Install both the top and bottom packages in the top installation scope. 2c. Run setup on both. Solution: To get a starting point to work from, first make some ugly special cases to solve these specific packages. Work on a generic solution from here. htdp-lib and deinprogramm-signature have a true circular dependency that can be solved by (2) (verified with htdp-lib as top). racket-doc and drracket have a circular dependency that works by just doing (1) -- force both to not do any setup for now. The racket-doc package has a whole drove of circular dependencies with other -doc packages. For discussion of next steps, see issue #38. --- racket2nix | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/racket2nix b/racket2nix index d7872a4..b1ff7d5 100755 --- a/racket2nix +++ b/racket2nix @@ -6,6 +6,8 @@ (define never-dependency-names '("racket")) (define always-build-inputs '("racket")) (define terminal-package-names '("racket-lib")) +(define remove-dependencies-for-package '#hash( + ("htdp-lib" . ("deinprogramm-signature")))) (define header-template #< {} @@ -44,8 +46,16 @@ stdenv.mkDerivation rec { buildInputs = [ unzip ~a ]; circularBuildInputs = [ ~a ]; + circularBuildInputsStr = stdenv.lib.concatStringsSep " " circularBuildInputs; - unpackPhase = "unzip $src -d $name"; + unpackPhase = '' + unzip $src -d $name + case $name in + htdp-lib) + unzip ${_deinprogramm-signature.src} -d deinprogramm-signature + ;; + esac + ''; patchPhase = '' case $name in @@ -90,7 +100,7 @@ stdenv.mkDerivation rec { mkdir -p $out/etc/racket $out/share/racket sed -e 's|$out|'"$out|g" > $out/etc/racket/config.rktd < $racketConfigPath - remove_deps="${stdenv.lib.concatStringsSep " " circularBuildInputs}" + remove_deps="${circularBuildInputsStr}" if [[ -n $remove_deps ]]; then sed -i $(printf -- '-e s/"%s"//g ' $remove_deps) $name/info.rkt fi @@ -105,9 +115,18 @@ stdenv.mkDerivation rec { 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 - ${raco} setup --no-user --no-pkg-deps --fail-fast --only --pkgs $name + 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))" && + [ -z "${circularBuildInputsStr}" ]; then + install_names=$(for install_info in ./*/info.rkt; do echo ''${install_info%/info.rkt}; done) + ${raco} pkg install --no-setup --copy --deps fail --fail-fast --scope installation $install_names + for install_name in $install_names; do + case $install_name in + racket-doc|drracket) ;; + *) + ${raco} setup --no-user --no-pkg-deps --fail-fast --only --pkgs ''${install_name#./} + ;; + esac + done fi find $out/share/racket/collects -lname '${_racket-lib.out}/share/racket/collects/*' -delete find $out/share/racket/collects -type d -empty -delete @@ -116,7 +135,10 @@ stdenv.mkDerivation rec { EOM ) -(define (derivation name url sha1 dependency-names circular-dependency-names) +(define (derivation name url sha1 raw-dependency-names circular-dependency-names) + (define dependency-names (remove* (hash-ref remove-dependencies-for-package name + (lambda () '())) + raw-dependency-names)) (define build-inputs (string-join (append always-build-inputs