From 63e2147b5b4687d3a245c4d829b47ffdfbf36ae0 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: Tue, 27 Feb 2018 19:59:55 +0800 Subject: [PATCH 1/6] Problem: links-search-files is set incorrectly Solution: Set to the file name, not the name of the directory name. New problem: This makes document generation work fully, which breaks for e.g. r6rs-doc. --- racket2nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/racket2nix b/racket2nix index c1ba8ca..3b790c5 100755 --- a/racket2nix +++ b/racket2nix @@ -123,10 +123,10 @@ EOM (string-join (for/list ((name circular-dependency-names)) (format "\"~a\"" name)))) - (define link-dirs + (define link-files (string-join (for/list ((name dependency-names)) - (format "\"${_~a.out}/share/racket\"" name)))) + (format "\"${_~a.out}/share/racket/links.rktd\"" name)))) (define pkgs-dirs (string-join (for/list ((name dependency-names)) @@ -137,7 +137,7 @@ EOM (format "\"${_~a.out}/share/racket/collects\"" name)))) (format derivation-template name url sha1 build-inputs circular-build-inputs - link-dirs pkgs-dirs collects-dirs)) + link-files pkgs-dirs collects-dirs)) (define (header) header-template) From a50b9ccbc51a4ae95853bf48ac8a99d5752a5eca 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 02:54:14 +0800 Subject: [PATCH 2/6] Problem: link-files adjustment is incomplete The own links file was not pointed to. Solution: Adjust own links file in the template. --- racket2nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/racket2nix b/racket2nix index 3b790c5..7d8f798 100755 --- a/racket2nix +++ b/racket2nix @@ -44,7 +44,7 @@ stdenv.mkDerivation rec { racketConfig = '' #hash( (share-dir . "$out/share/racket") - (links-search-files . ( "$out/share/racket" ~a )) + (links-search-files . ( "$out/share/racket/links.rktd" ~a )) (pkgs-search-dirs . ( "$out/share/racket/pkgs" ~a )) (collects-search-dirs . ( "$out/share/racket/collects" ~a )) (absolute-installation . #t) From f2019380c8ff449fd1dca7291c5a1f676ed5ad57 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 04:19:21 +0800 Subject: [PATCH 3/6] Problem: some packages want to write to $HOME when building Packages that depend on racket-index want to write to $HOME when building their documentation. racket-index wants to update its documentation database in the user scope, if it can't find the database in installation scope. Solution: For now, patch racket-index to always write to installation scope. --- racket2nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/racket2nix b/racket2nix index 7d8f798..f908142 100755 --- a/racket2nix +++ b/racket2nix @@ -14,6 +14,20 @@ , racket ? pkgs.racket-minimal , racket-lib ? racket , unzip ? pkgs.unzip +, racketIndexPatch ? builtins.toFile "racket-index.patch" '' + diff --git a/pkgs/racket-index/setup/scribble.rkt b/pkgs/racket-index/setup/scribble.rkt + index c79af9bf85..e4a1cf93e3 100644 + --- a/pkgs/racket-index/setup/scribble.rkt + +++ b/pkgs/racket-index/setup/scribble.rkt + @@ -874,6 +874,7 @@ + [(not latex-dest) (build-path (doc-dest-dir doc) file)])) + + (define (find-doc-db-path latex-dest user? main-doc-exists?) + + (set! main-doc-exists? #t) + (cond + [latex-dest + (build-path latex-dest "docindex.sqlite")] + '' }: @@ -33,6 +47,14 @@ stdenv.mkDerivation rec { unpackPhase = "unzip $src -d $name"; + patchPhase = '' + case $name in + racket-index) + ( cd racket-index && patch -p3 < ${racketIndexPatch} ) + ;; + esac + ''; + dontBuild = true; racket-cmd = "${racket.out}/bin/racket -G $out/etc/racket -U -X $out/share/racket/collects"; From f698f860432fe477ae856d6392b229376a3df1e6 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 06:35:59 +0800 Subject: [PATCH 4/6] Problem: We have workaround code that is no longer necessary When we corrected the problem with our own links-file, the workaround of creating directories in .../collects became unnecessary. Solution: Remove the workaround. --- racket2nix | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/racket2nix b/racket2nix index f908142..78bbe19 100755 --- a/racket2nix +++ b/racket2nix @@ -106,26 +106,6 @@ 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 -lname '${_racket-lib.out}/share/racket/collects/*' -delete From 1d3d093ec0a64bfb1e5cd25dd24e57d43c48dca2 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 02:55:57 +0800 Subject: [PATCH 5/6] Problem: doc-search-dirs is incorrect While troubleshooting other attributes, I discovered that the default doc-search-dirs ends up being $package/share/racket/collects/doc. Solution: Make doc-search-dirs explicit in config.rktd. --- racket2nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/racket2nix b/racket2nix index 78bbe19..d7872a4 100755 --- a/racket2nix +++ b/racket2nix @@ -69,6 +69,7 @@ stdenv.mkDerivation rec { (links-search-files . ( "$out/share/racket/links.rktd" ~a )) (pkgs-search-dirs . ( "$out/share/racket/pkgs" ~a )) (collects-search-dirs . ( "$out/share/racket/collects" ~a )) + (doc-search-dirs . ( "$out/share/racket/doc" ~a )) (absolute-installation . #t) (installation-name . ".") ) @@ -137,9 +138,13 @@ EOM (string-join (for/list ((name dependency-names)) (format "\"${_~a.out}/share/racket/collects\"" name)))) + (define doc-dirs + (string-join + (for/list ((name dependency-names)) + (format "\"${_~a.out}/share/racket/doc\"" name)))) (format derivation-template name url sha1 build-inputs circular-build-inputs - link-files pkgs-dirs collects-dirs)) + link-files pkgs-dirs collects-dirs doc-dirs)) (define (header) header-template) 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 6/6] 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