diff --git a/guix/grafts.scm b/guix/grafts.scm index d6b0e93e8..88a99312d 100644 --- a/guix/grafts.scm +++ b/guix/grafts.scm @@ -75,6 +75,36 @@ (($ (? string? item)) item))) +(define (fix-racket-checksums store drv system) + (define racket-drv + (let ((package-derivation (module-ref (resolve-interface '(guix packages)) + 'package-derivation)) + (racket (module-ref (resolve-interface '(gnu packages scheme)) + 'racket))) + (package-derivation store racket system #:graft? #f))) + + (define hook-exp + `(lambda (input output mapping) + (let ((raco (string-append output "/bin/raco"))) + ;; Setting PLT_COMPILED_FILE_CHECK to "exists" tells Racket to + ;; ignore timestamps when checking if a compiled file is valid. + ;; Without it, Racket attempts a complete rebuild of + ;; everything. + (setenv "PLT_COMPILED_FILE_CHECK" "exists") + ;; All of the --no-* flags below keep Racket from making + ;; unecessary and unhelpful changes (like rewriting scripts and + ;; reverting their shebangs in the process). + (invoke raco "setup" "--no-launcher" "--no-install" + "--no-post-install" "--no-info-domain" "--no-docs")))) + + (if (string=? (derivation-file-name drv) + (derivation-file-name racket-drv)) + hook-exp + #f)) + +(define %graft-hooks + (list fix-racket-checksums)) + (define* (graft-derivation/shallow store drv grafts #:key (name (derivation-name drv)) @@ -104,6 +134,11 @@ are not recursively applied to dependencies of DRV." (assoc-ref (derivation-outputs drv) output)))) outputs)) + (define hook-exps + (filter-map (lambda (hook) + (hook store drv system)) + %graft-hooks)) + (define build `(begin (use-modules (guix build graft) @@ -120,7 +155,10 @@ are not recursively applied to dependencies of DRV." (for-each (lambda (input output) (format #t "grafting '~a' -> '~a'...~%" input output) (force-output) - (rewrite-directory input output mapping)) + (rewrite-directory input output mapping) + ,@(map (lambda (exp) + `(,exp input output mapping)) + hook-exps)) (match old-outputs (((names . files) ...) files))